文章出處
文章列表
最近swift有點火,趕緊跟上學習。于是,個人第一個swift程序誕生了。。。
新建項目
選擇ios應用,單視圖應用
隨便起個項目名稱,語言選擇“swift”
項目建好了,我們這里只需要在AppDelegate.swift
文件里加上幾行代碼就ok
你會看到下面這個方法。從注釋可以看出,應用加載后就會運行這個方法
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
return true
}
在return true
之前加上這幾行代碼,搞定
// 我們的代碼
var alert = UIAlertView()
alert.title = "標題"
alert.message = "hello world"
alert.addButtonWithTitle("確定")
alert.show()
為方便調試,我們選擇ios模擬器,如下圖位置,這里選擇iphone 4s
運行程序
如果看到下面界面,恭喜!
文章列表
全站熱搜