2012-08-05 3 views
0

앱이 활성화되어있는 경우 알림을 표시하려면 다음 코드를 따라야합니다. AppDelegate.m에 넣습니다.알림 버튼을 누른 후 전환 수행

사용자가 두 번째 단추를 누르면 뷰 컨트롤러로 전환 (또는 세그)을 수행하려고합니다. 어떻게 AppDelegate에서이 작업을 수행 할 수 있습니까?

나는 navigationcontroller를 appdelegate로 설정해야한다고 생각한다. 그러나 나는 이것을 달성 할 수 없었다.

감사

당신이 UINavigationController가 사용할 수있는 옵션으로
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
    UIApplicationState state = [application applicationState]; 
    if (state == UIApplicationStateActive) { 
     NSString *cancelTitle = @"Close"; 
     NSString *showTitle = @"Show"; 
     //NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"]; 
     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Social Dilemma" 
                  message:@"Next round is ready to play!" 
                  delegate:self 
                cancelButtonTitle:cancelTitle 
                otherButtonTitles:showTitle, nil]; 
     [alertView show]; 
    } 
} 

-(void) alertView: (UIAlertView *) alertView 
clickedButtonAtIndex: (NSInteger) buttonIndex { 
    if (alertView.tag == 1) 
    { 
     //check the button index 
     //create and display the other alert view (set the tag property here to 2) 
    } 
    else if (alertView.tag == 2) 
    { 

    } 
} 

답변

0

,이 컨트롤러 당신의 응용 프로그램이 얼마나 많은보기 달려있다. 간단한 방법으로, 당신은 응용 프로그램의 루트 컨트롤러에 존재하는 모달 뷰 컨트롤러를 호출 시도 할 수 있습니다 : MyViewController)

2)

: 1) 사용자의 UIViewController (.H,하는 .m, .xib) (예 이름을 프로젝트에 추가 응용 프로그램의 didFinishLaunchingWithOptions에서, uinavigation 컨트롤러를 사용하기 위해
-(void) alertView: (UIAlertView *) alertView 
    clickedButtonAtIndex: (NSInteger) buttonIndex { 
    if (alertView.tag == 1) 
    { 
     //check the button index 
     //create and display the other alert view (set the tag property here to 2) 
     MyViewController *first = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; 
     [self.window.rootViewController presentModalViewController:first animated:YES]; 
     [first release]; 
    } 
    else if (alertView.tag == 2) 
    { 
     MyViewController *second = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; 
     [self.window.rootViewController presentModalViewController:second animated:YES]; 
     [second release]; 
    } 
} 

: 당신은 프로그램 호출, 네비게이션 컨트롤러를 만들 루트 컨트롤러 및 경고보기의 방법을 지정할 수 있습니다

[self.window.rootViewController pushViewController:second (first) animated:YES];