简体   繁体   English

调用didFinishLaunchingWithOptions时,应用崩溃

[英]App crashes when didFinishLaunchingWithOptions is called

I have an the app when notification is fired i get a notification bar when the app is in background ,when i tap on that bar it navigates into tableview of the notification set . 触发通知时,我有一个应用程序。当应用程序处于后台时,我会收到一个通知栏,当我点击该栏时,它会导航到通知集的tableview中。 When i quit the app from background i am receiving notification but when tap on the notification bar the app is getting crashed since its not getting indexpath of the tableview. 当我从后台退出应用程序时,我会收到通知,但是在通知栏上点击时,应用程序将崩溃,因为它没有获取tableview的indexpath。

When the app is quit in background and reloading the app should enter didfinishlaunching. 当应用在后台退出并重新加载时,应进入didfinishlaunching。

In appDidFinishLaunching i am calling the method which navigates into tableview 在appDidFinishLaunching中,我正在调用导航到tableview的方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[PPViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] ;

     UILocalNotification *notification = [launchOptions objectForKey:              UIApplicationLaunchOptionsLocalNotificationKey];

    if (notification)
        {
            int remedyID = [[notification.userInfo objectForKey:kRemindMeNotificationRemedyIDKey] intValue];
            NSDictionary *reminderDetails =[NSDictionary dictionaryWithObjectsAndKeys:notification.userInfo,@"kRemindMeNotificationDataKey",[NSNumber numberWithInt:remedyID],kRemindMeNotificationRemedyIDKey,nil];

            [_viewController goToReminder:reminderDetails showNotification:YES];

       }
     [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
    self.viewController = [[PPViewController alloc] initWithNibName:@"PPViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;

}

**This is the code which navigates into tableview in another viewcontroller**

- (void)goToReminder:(NSMutableDictionary *)reminderDictionary showNotification:(BOOL)shouldShowNotification

{
    NSIndexPath *selectedSymptIP = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber];

    [self tableView:symptomsTableView didSelectRowAtIndexPath:selectedSymptIP];

}

When you quit the app and your app starts again, your viewController is not yet set up. 当您退出应用程序并且应用程序再次启动时,您的viewController尚未设置。 When launching from a notification, you need to check if you are resuming from the background, or launching normally. 从通知启动时,需要检查是从后台恢复还是正常启动。

Look at applicationWillEnterForeground and applicationDidBecomeActive in the UIApplicationDelegate protocol reference for how to handle resuming your app from various states. UIApplicationDelegate协议参考中查看applicationWillEnterForegroundapplicationDidBecomeActive ,以了解如何处理从各种状态恢复应用程序的问题。 Also see: http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW3 另请参阅: http : //developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW3

我能够解决问题..由于加载错误的xib文件而发生崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iPhone应用程序在didFinishLaunchingWithOptions之前崩溃 - Iphone app crashes before didFinishLaunchingWithOptions didFinishLaunchingWithOptions未调用,但应用程序正在运行并面临崩溃 - didFinishLaunchingWithOptions not called but app is running and faced with crash didFinishLaunchingWithOptions未调用 - didFinishLaunchingWithOptions not called IOS调用didFinishLaunchingWithOptions时的条件 - Conditions when didFinishLaunchingWithOptions get called by the IOS didFinishLaunchingWithOptions没有被调用 - didFinishLaunchingWithOptions not being called 当UITabBarControllerDelegate调用时,popToRootViewController崩溃 - popToRootViewController crashes when called by UITabBarControllerDelegate 在完成Storyboard加载之前调用应用程序didFinishLaunchingWithOptions? - application didFinishLaunchingWithOptions is called before Storyboards are done loading? 触摸时应用崩溃 - App Crashes when touched Xcode通用应用程序模板,并覆盖didFinishLaunchingWithOptions - Xcode universal app templates, and overriding didFinishLaunchingWithOptions 将纬度和经度坐标发送到应用程序委托中的didFinishLaunchingWithOptions - Sending latitude and longitude coordinates to the didFinishLaunchingWithOptions in the app delegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM