Xcode快速入门-2-第一个APP - Hello World
2015-10-23 14:14
495 查看
1、建立专案:
a.选择第二项:Create a new Xcode project
b.iOS中选择Application中的Single View Application
c.product name:APP名称
organization name:组织名称
organization identifier:网域名
bundle identifier:APP识别码(自动产生)
language:开发语言=>选SWIFT
devices:iPhone
Use Core Data:不勾选
下一步,选择存储代码文件夹
2、在左侧档案检阅器(Interface Builder Document)选择Main.storyboard,将「Use Size Classes」前面的勾取消,这时Xcode会提示选择一个目标,选择iPhone。
3、在视图上加上按钮
a.右下方的工具区块中,会列出元件库(Object Library),把按键拖拉到故事板中。
b.修改按钮名称为-Hello World
4、加上代码
在Project Navigator中找到ViewController.swift,在原有的
super.viewDidload()
override func didReceiveMemoryWarining()
这两个方法下面加上
5、建立代码和按钮间的连结
按着control键不方,点选按钮,拖拉到View Controller的图标上,选择刚才写好的方法showMessage做为动作连结。
6、完成,可以直接测试了。
a.选择第二项:Create a new Xcode project
b.iOS中选择Application中的Single View Application
c.product name:APP名称
organization name:组织名称
organization identifier:网域名
bundle identifier:APP识别码(自动产生)
language:开发语言=>选SWIFT
devices:iPhone
Use Core Data:不勾选
下一步,选择存储代码文件夹
2、在左侧档案检阅器(Interface Builder Document)选择Main.storyboard,将「Use Size Classes」前面的勾取消,这时Xcode会提示选择一个目标,选择iPhone。
3、在视图上加上按钮
a.右下方的工具区块中,会列出元件库(Object Library),把按键拖拉到故事板中。
b.修改按钮名称为-Hello World
4、加上代码
在Project Navigator中找到ViewController.swift,在原有的
super.viewDidload()
override func didReceiveMemoryWarining()
这两个方法下面加上
@IBAction func showMessage(){ let alertController = UIAlertController(title: "Welcome to My First App", message: "Hello Wolrd", preferredStyle : UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) self.presentViewController(alertController, animated: true, completion: nil) }
5、建立代码和按钮间的连结
按着control键不方,点选按钮,拖拉到View Controller的图标上,选择刚才写好的方法showMessage做为动作连结。
6、完成,可以直接测试了。
相关文章推荐
- Android各种轮子
- App项目升级Xcode7&iOS9(续) - This bundle is invalid. The bundle identifier contains disallowed characters
- Eclipse Android 代码自动提示消失解决办法Java xml
- 手机端的mousedown
- System Permissions
- Android中CountDownTimer倒计时器用法实例
- Android自定义控件及自定义属性
- Android自定义控件及自定义属性
- App项目升级Xcode7&iOS9(续) - This bundle is invalid. The bundle identifier contains disallowed characters
- swift:Optional Type 、Swift和Objective-C混编的讲解
- Android Developper 学习
- iOS webView展示gif图(登录时背景图动态gif)
- iOS 多图轮播
- 解决Android Studio/Idea在EI Captian下字体显示不正常的问题
- Android对接微信支付体验
- 如何区别Android手机卡三大运营商
- Android仿ios录音动画
- Android Studio开发入门-引用jar及so文件
- 制作静态库
- iOS 开发中如何使用半透明模糊效果