2014-02-17 4 views
2

푸시 알림을 사용할 수있는 3 개의보기 컨트롤러와 앱이있는 스토리 보드가있는 앱을 개발하고 있습니다. 푸시 알림을받을 때 알림 알림을 탭하면 내 스토리 보드에서 두 번째보기 컨트롤러를 열어야 내 코드를 표시 할 수 있습니다. 또한 두 번째보기 컨트롤러로에있는 버튼이 그 내가로드 할 컨트롤러 인 실제로 내 첫 번째보기 컨트롤러apple pushnotification을받을 때 storyboard에서 viewcontroller를 엽니 다.

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
     [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo]; 

} 

다음 스토리 보드로드합니다. 여기 첫 번째보기 컨트롤러의 코드가 있습니다.

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil]; 
} 
-(void)pushNotificationReceived{ 
    NSString * storyboardName = @"DealerMainStoryboard"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; 
    UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"DealerBuyRequests"]; 
    [self presentViewController:vc animated:YES completion:nil]; 
} 

알림을받을 때이 코드로 알림을받을 때 앱이 다운됩니다.

+0

그리고 어디에 문제가 있습니까? – iCode

+0

푸시 알림이 표시되고 알림을 탭하면 앱이이 코드와 충돌합니다. – user2966615

+0

오류 로그 란 무엇입니까? – iCode

답변

0

일부 오류 로그를 받아야하지만이를 확인해야합니다.

UIViewController * vc = 
     [storyboard instantiateViewControllerWithIdentifier:@"DealerBuyRequests"]; 

난 당신이 정말 컨트롤러 "의 UIViewController"라는하지 않는 한, 새로운 UIViewController을 만들려는 생각하지 않습니다.

그래서 다시는 모달

DealerBuyRequestsViewController * vc = 
     [storyboard instantiateViewControllerWithIdentifier:@"DealerBuyRequests"]; 

이보기 컨트롤러의 StoryBoard IdDealerBuyRequests 일치하거나 오류를 얻을 것이다 있는지 확인합니다 제시 할 뷰의 클래스 이름을 확인합니다.