2011-11-28 2 views
2

iOS 5 및 스토리 보드를 사용하면 사용자가 로컬 알림을받은 후 앱을 입력 할 때보기를 표시하는 가장 좋은 방법은 무엇입니까?로컬 알림을받을 때의 현재보기

나는 NSNotificationCenter를 사용하는 것이 그것을 할 수있는 방법이라고 읽었지만 스토리 보딩과 단조로 그것도 그렇습니까?

답변

3

정확하게 구현 한 방법입니다. AppDelegate에의 didFinishLaunchingWithOptions에서 : 나는 한 곳에서 논리를 유지할 수 있도록

UILocalNotification *notification = 
    [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
    [self application:application didReceiveLocalNotification:notification]; 

내가 이런 짓을 : 방법, 나는 다음과 같은했다. didreceiveLocalNotification에서 :

// Let another view handle the display   
    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; 
    [nc postNotificationName:@"SHOW_VERSE" 
         object:self 
        userInfo:notification.userInfo]; 

스토리에 대한 최초의 UIViewController 인 표시를 처리하는 관점 :있어서, I는 다음 NSNotificationCenter를 사용했다. 이 클래스에서 viewDidLoad 메서드로 :

[[NSNotificationCenter defaultCenter] addObserver:self 
        selector:@selector(receivedLocalNotification:) 
         name:@"SHOW_VERSE" 
        object:nil]; 

이 방법은 저에게 매우 효과적입니다. 희망이 도움이됩니다.

+0

통지가 게시되기 전에 viewDidLoad 메소드가 호출되고 (통지 핸들러가 등록 됨) 어떻게 보장합니까? – elsurudo

관련 문제