[英]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
协议参考中查看applicationWillEnterForeground
和applicationDidBecomeActive
,以了解如何处理从各种状态恢复应用程序的问题。 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.