2015-02-06 3 views
0

UIAlertview를 표시하는 뷰 컨트롤러 메서드를 호출 중이며 alertview가 표시되지만 인덱스 메서드에서 클릭 한 단추가 호출 중이 아닙니다. 그것을 고치는 방법?AppDelegate에서 하나의보기 컨트롤러 클래스의 UIAlertView를 표시하고 경고 단추를 클릭하면 인덱스 메서드에서 클릭 한 단추를 누르는 방법?

다음 코드는 TestViewController 클래스

- (void) test 
{ 
    UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"OPTUM" message:NSSAlertMessage delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil]; 
      alert1.tag = 3; 
      [alert1 show]; 
} 

에서 사용하고 도움을, 같은 애플 대리자에서 미리

- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 

    NSLog(@"Notification Received: %@", userInfo); 
    NSString *NSSMessage = [NSString stringWithFormat:@"%@", userInfo]; 
    UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
     TestViewController *obj1=[storyboard instantiateViewControllerWithIdentifier:@"View Controller"]; 
     [obj1 handleNotificationMessage: NSSMessage]; 
} 

감사를 위의 방법을 호출했다.

+1

클래스에서 clickedButtonAtIndex를 구현하고 있습니까? – dminones

+0

인덱스에서 클릭 한 버튼이 TestVIewController 클래스에 있지만 지금은 App Delegate로 이동했습니다. 그 지금 일하고있어. 응답을 주셔서 대단히 감사합니다. – Sakthimuthiah

답변

0

당신의 전화 뷰 컨트롤러가 UIAlertViewDelegate로 선언되어 있는지 확인합니다 :

@interface TestViewController : UIViewController<UIAlertViewDelegate> 

그리고 clickedButtonAtIndex 올바른 서명이 있는지 확인 : 나는 follwing을 대답은 씨에 근무하고 감사했다 발견

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
+0

예, 이미 위임 된 delegate와 clickedButtonAtIndex도 제공했습니다. – Sakthimuthiah

관련 문제