要知道的重要事項我猜是我正在使用故事板。我做在didFinishLaunchingWithOptions以下:故事板 - initWithCoder被調用兩次
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
FirstView *mvc = [sb instantiateViewControllerWithIdentifier:@"FirstView"];
SecondView *tvc = [sb instantiateViewControllerWithIdentifier:@"SecondView"];
NSArray* controllers = [NSArray arrayWithObjects:[self addNavigationToViewController:mvc], [self addNavigationToViewController:tvc], nil];
// add controllers to a table view
UITabBarController *tb = [[UITabBarController alloc] init];
[tb setViewControllers:controllers];
[self.window setRootViewController:tb];
addNavigationToViewController是我使用以嵌入一個UINavigationController
內部的視圖控制器的方法當運行此應用程序initWithCoder
在FirstView被調用兩次。我找到了原因,但我不知道如何以正確的方式做到這一點。
基本上的firstView是越來越由於它是初始場景初始化一次(有在屬性檢查員,設置視圖的複選標記「在初始視圖控制器」)和第二時間:
FirstView *mvc = [sb instantiateViewControllerWithIdentifier:@"FirstView"];
如果我取消選中初始場景它會抱怨「可能指定的入口點未設置」。
我做錯了什麼,但我不知道它是什麼。
任何提示,將不勝感激。
我有完全相同的問題...雖然我從來沒有調用「instantiateViewControllerWithIdentifier」方法。我正在使用「純」故事板(例如,沒有在源代碼中實例化控制器)。任何想法爲什麼「initWithCoder」方法被調用兩次? – CedX