I had this same issue when my app was first launching. What I found was that in my MainWindow.xib file, I was setting both my App Delegate's viewController
outlet, and my Window's rootViewController
outlet to my root view controller. When you build a View Based project file in Xcode, your App Delegate's didFinishLaunchingWithOptions
will be pre-populated with:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
I believe that the self.viewController
ivar is instantiated from MainWindow.xib before didFinishLaunchingWithOptions
gets called. Then the pre-populated code above sets the Window's rootViewController
. So if, in conjunction, you specify the rootViewController
outlet for the Window in your MainWindow.xib file, your root view controller will actually be created twice and added as the Window's root view controller two times.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…