[已解决]swift中makeKeyAndVisible的作用

看到别人教程中,常常出现:
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()

Discussion

This is a convenience method to make the receiver the main window and displays it in front of other windows at the same window level or lower. You can also hide and reveal a window using the inherited hidden property of UIView.
好像就只是:
[总结]
makeKeyAndVisible的作用:
让此window作为主窗口
-》当然app一直只有一个window
-》所以此处调用或不调用makeKeyAndVisible,都不影响当前window是主窗口
注:同一时刻,只有一个主窗口


发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量