[英]App crashes on iPhone 5 when calling the Viewcontroller in delegate
我有一个在其他模拟器(包括The New iPad)中运行良好的项目。 但是,使用iPhone5,在委托中调用Viewcontroller时会崩溃,我不知道为什么会发生此错误。 如果您在以下代码中发现任何可能的原因,请告诉我:
self.rootviewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
self.rootNavController = [[UINavigationController alloc]
self.rootNavController.navigationBar.hidden=YES;
[window addSubview:rootNavController.view];'
非常感谢你
我认为您在创建UINavigationController
做错了什么,请尝试以下代码在AppDelegate.m
替换您的代码:
编辑添加代码以使用UIViewController
显示和删除初始屏幕
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Create View Controller
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
// Create Navigation Controller
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
// Create Navigation Controller
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
// SplashScreen
[self displaySplashscreen];
return YES;
}
#pragma mark - SplashScreen Methods
- (void)displaySplashscreen
{
// Create View
self.splashscreenViewController = [[SplashscreenViewController alloc] init];
// Display Splashscreen
[_window addSubview:_splashscreenViewController.view];
// Dismiss Splashscreen
[self performSelector:@selector(dismissSplashscreen) withObject:nil afterDelay:3.0f]; // Modify the time
}
- (void)dismissSplashscreen
{
// Splashscreen Animation
[UIView animateWithDuration:0.5f
animations:^{
_splashscreenViewController.view.alpha = 0.0f;
} completion:^(BOOL finished) {
[_splashscreenViewController.view removeFromSuperview];
}];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.