0

我有一个项目在包括 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];'

请看下图: 错误

非常感谢

4

1 回答 1

1

我认为您在创建时做错了,请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];
                     }];
}
于 2013-11-05T16:37:32.023 回答