簡體   English   中英

在代理中調用Viewcontroller時,iPhone 5上的應用程序崩潰

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM