我收到的錯誤:如何解決錯誤「類的appDelegate沒有初始化」
Class AppDelegate has no initializers
,似乎無法理解爲什麼。我正在關注this tutorial。我是初學者,所以任何幫助將非常感激!
我的代碼:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var centerContainer: MMDrawerController
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
_ = self.window!.rootViewController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let centerViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let leftViewController = mainStoryboard.instantiateViewController(withIdentifier: "LeftSideViewController") as! LeftSideViewController
let leftSideNav = UINavigationController(rootViewController: leftViewController)
let centerNav = UINavigationController(rootViewController: centerViewController)
centerContainer = MMDrawerController(center: centerNav, leftDrawerViewController: leftSideNav)
centerContainer.openDrawerGestureModeMask = MMOpenDrawerGestureMode.panningCenterView;
centerContainer.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.panningCenterView;
window!.rootViewController = centerContainer
window!.makeKeyAndVisible()
return true
}
}
'centerContainer'是否需要屬性?除了'didFinishLaunchingWithOptions'方法之外,還會從其他代碼訪問嗎? – rmaddy
[Class沒有初始化器Swift]可能的重複(http://stackoverflow.com/questions/27797351/class-has-no-initializers-swift) –