2010-08-23 4 views
1

푸시 알림이 수신 될 때 (앱이 실행되는 동안) 알림 모달을 표시해야합니다. 내 앱에는 탭 표시 줄이 있으며, 알림 모달을 탭 표시 줄 컨트롤러로 밀어 넣어 부분적으로 작동하도록했습니다.푸시 알림을받을 때 모달 표시

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {   
    NotificationViewController *vc = [[NotificationViewController alloc] init]; 
    [tabBarController presentModalViewController:vc animated:YES]; 
    [vc release]; 
} 

그러나 이것은 이미 탭 바 컨트롤러를 숨기는 다른 모달 오픈이있는 경우에는 실패합니다. 탭 표시 줄 컨트롤러를 숨기고있는 모달 열림이 있어도 NotificationViewController 이 항상이 표시되도록하는 가장 좋은 방법은 무엇입니까?

답변

3

할 수있는 일이 두 가지 있습니다. 첫 번째는 현재의 모달 컨트롤러를 없애는 것이지만, 사용자를 혼란스럽게 할 수 있습니다. 이 모달 컨트롤러에서 다른 모달 컨트롤러를 엽니로,

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {  
    UIViewController* currentController = tabBarController; 
    if ([currentController modalViewController] != nil) 
      currentController = [currentController modalViewController]; 

    NotificationViewController *vc = [[NotificationViewController alloc] init]; 
    [currentController presentModalViewController:vc animated:YES]; 
    [vc release]; 
} 

가 아마 가장 예쁜 것은 할 수없는,하지만 작동 : 두 번째 점은 같은 것입니다.

+0

내 용도로는 잘 작동합니다. 고맙습니다. –

관련 문제