2013-05-21 2 views
0

알림이 실행될 때 앱이 있습니다. 앱이 백그라운드에있을 때 알림 바가 표시됩니다. 알림 바의 탭을 탐색 할 때 알림 바를 탭하면됩니다. 내가 배경에서 응용 프로그램을 종료하면 알림을 받고 있지만 통지 표시 줄 탭 때 응용 프로그램이 tableview의 indexpath를 가져 오지 않아 충돌이 발생합니다.didFinishLaunchingWithOptions가 호출 될 때 앱이 충돌합니다.

앱이 백그라운드에서 종료되고 다시로드되면 앱이 didfinishlaunching을 입력해야합니다. appDidFinishLaunching에서

난 당신이 응용 프로그램을 종료하고 앱이 viewController가 아직 설정되지 않은, 다시 시작할 때의 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]; 

} 
+1

앱이 어떤 라인에서 충돌하고 있습니까? 충돌 로그가 있습니까? –

+0

@Ric 앱이 백그라운드에서 종료되고 알림 바를 클릭하여 알림이 시작되면 앱이 다운됩니다. 앱이 백그라운드에서 실행 중이고 알림이 시작된 경우 ... 바를 클릭하면 앱이 제대로 탐색합니다. – raptor

+0

감사합니다. 'application didFinishLaunchingWithOptions :'의 첫 번째 줄에 중단 점을 설정하고 메서드를 단계별로 실행하면 충돌이 어디에서 발생합니까? 내 생각 엔 userInfo가 제대로 디코딩되지 않으면이 줄'int remedyID = [[notification.userInfo objectForKey : kRemindMeNotificationRemedyIDKey] intValue];가 문제가 될 수 있습니다. –

답변

0

문제를 해결할 수있었습니다. 잘못된 xib 파일이로드 되었기 때문에 충돌이 발생했습니다.

0

로 탐색 메서드를 호출하고 있습니다. 알림에서 시작할 때 백그라운드에서 다시 시작하는지 또는 정상적으로 시작하는지 확인해야합니다.

다양한 주에서 앱을 다시 시작하는 방법은 UIApplicationDelegate 프로토콜 참조에서 applicationWillEnterForegroundapplicationDidBecomeActive을 참조하십시오. 또한 참조 : http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW3

+0

steve 나는 위임자 프로토콜에서 시도했다. – raptor

관련 문제