本文介绍了iOS-viewDidLoad在didFinishLaunchingWithOptions委托之前被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
然而,我把一个断点放在我的rootViewController的viewDidLoad方法的第一行,另一个断点在我的代表的第一行didFinishLaunchingWithOptions,
令人惊讶的是,我在应用程序中输入了viewDidLoad方法,然后去了didFinishLaunchingWithOptions,然后再执行一次viewDidLoad方法。
发生了什么事?我认为这种行为是完全错误的。
提前谢谢!
#
编辑
这里是我的iPad的代表didFinishLaunchingWithOptions方法:
- (BOOL)应用程序: (UIApplication *)应用程序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];
返回YES;
}
这里是我的iPhone的代表didFinishLaunchingWithOptions方法:
$ b $ (UIApplication *)应用程序didFinishLaunchingWithOptions :( NSDictionary *)launchOptions{
[[UIApplication sharedApplication] setStatusBarHidden :没有];
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];
返回YES;
}
这两个设备都发生这种奇怪的行为。
解决方案
So the view is lazily loaded for view controllers once the the view
property or method is called. When this happens viewDidLoad
is called so if your window rootViewController
property is set to your root ViewController in the nib then this is expected behavior.
这篇关于iOS-viewDidLoad在didFinishLaunchingWithOptions委托之前被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!