我有一個正常工作的應用程序。iOS - viewDidLoad在didFinishLaunchingWithOptions委託之前被調用?
但是,我把我的RootViewController的的viewDidLoad方法的第一線,在我委託的didFinishLaunchingWithOptions的第一行另一個斷點一個斷點,
令人驚訝的對我來說,在viewDidLoad方法進入應用,然後去didFinishLaunchingWithOptions,然後再執行一次viewDidLoad方法。
這是怎麼回事?我認爲那種行爲是完全錯誤的。
預先感謝您!
# 編輯這裏去我的iPad的委託didFinishLaunchingWithOptions方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
UtilXML *utilXML = [[UtilXML alloc] init];
[utilXML startXMLCommunication];
int quantidadeDeComicsBaixadas = [utilXML quantidadaDeComicsBaixadas];
main_iPad *mainiPad = [[main_iPad alloc] init];
mainiPad.quantidadeDeComicsBaixadas = quantidadeDeComicsBaixadas;
mainiPad.navigationItem.title = @"TitleFirstScreen";
UIBarButtonItem *botaoSobre = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:mainiPad action:@selector(goToAboutView)];
mainiPad.navigationItem.rightBarButtonItem = botaoSobre;
navController = [[UINavigationController alloc] initWithRootViewController:mainiPad];
navController.navigationBar.tintColor = [UIColor orangeColor];
navController.navigationBar.translucent = YES;
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;
}
這裏是我的iPhone的委託didFinishLaunchingWithOptions方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
UtilXML *utilXML = [[UtilXML alloc] init];
[utilXML startXMLCommunication];
int quantidadeDeComicsBaixadas = [utilXML quantidadaDeComicsBaixadas];
main_iPhone *mainiPhone = [[main_iPhone alloc] init];
mainiPhone.quantidadeDeComicsBaixadas = quantidadeDeComicsBaixadas;
mainiPhone.navigationItem.title = @"TitleFirstScreen";
UIBarButtonItem *botaoSobre = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:mainiPhone action:@selector(goToAboutView)];
mainiPhone.navigationItem.rightBarButtonItem = botaoSobre;
navController = [[UINavigationController alloc] initWithRootViewController:mainiPhone];
navController.navigationBar.tintColor = [UIColor orangeColor];
navController.navigationBar.translucent = YES;
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;
}
在兩個設備中出現這種奇怪的行爲。
你能否介紹一下你的應用程序委託中發生了什麼?你有多個應用程序代表文件? (即iPhone/iPad) – Luke