调用 didFinishLaunchingWithOptions 时应用程序崩溃 [英] App crashes when didFinishLaunchingWithOptions is called

查看:41
本文介绍了调用 didFinishLaunchingWithOptions 时应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当通知被触发时,我有一个应用程序,当应用程序处于后台时,我会收到一个通知栏,当我点击该栏时,它会导航到通知集的表格视图中.当我从后台退出应用程序时,我收到通知,但是当点击通知栏时,应用程序崩溃了,因为它没有获取 tableview 的索引路径.

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 . 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.

当应用在后台退出并重新加载应用时,应进入 didfinishlaunching.

在 appDidFinishLaunching 中,我正在调用导航到 tableview 的方法

In appDidFinishLaunching i am calling the method which navigates into 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];

}

推荐答案

我能够解决问题..由于加载了错误的 xib 文件而导致崩溃.

I was able to solve the problem ..the crash was occurring since wrong xib file was loaded .

这篇关于调用 didFinishLaunchingWithOptions 时应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆