【发布时间】:2016-12-13 13:13:25
【问题描述】:
我正在学习如何在没有 Interface Builder 的情况下创建 iOS 应用程序(即故事板、xib 等)。下面是我正在使用的基本应用程序委托类。问题是当显示UIWindow 时不会用完设备的全屏(见附件截图)。这发生在我测试的所有设备和模拟器上。为什么不使用全屏?
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
lazy var window: UIWindow? = {
debugPrint("AppDelegate: Creating Window")
let screen: UIScreen = UIScreen.mainScreen()
let window: UIWindow = UIWindow.init(frame: screen.bounds)
window.backgroundColor = UIColor.whiteColor()
return window
}()
lazy var rootViewController: ShapesViewController = {
debugPrint("AppDelegate: Creating Root View Controller")
let rootViewController = ShapesViewController.init(nibName: nil, bundle: nil)
return rootViewController
}()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
debugPrint("AppDelegate: applicationWillEnterForeground")
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()
return true
}
}
【问题讨论】:
标签: ios swift uikit uiwindow uiscreen