看到别人教程中,常常出现:
makeKeyAndVisible
比如:
但是自己试了试:
加上或不加上makeKeyAndVisible:
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. 。。。 self.window!.makeKeyAndVisible() return true }
好像没区别。
所以要去搞清楚:
swift makeKeyAndVisible
参考:
Makes the receiver the key window and visible.
Declaration
SWIFT
func makeKeyAndVisible()
好像就只是:
[总结]
makeKeyAndVisible的作用:
让此window作为主窗口
-》当然app一直只有一个window
-》所以此处调用或不调用makeKeyAndVisible,都不影响当前window是主窗口
注:同一时刻,只有一个主窗口
转载请注明:在路上 » [已解决]swift中makeKeyAndVisible的作用