0

내 응용 프로그램에 5-6 뷰 컨트롤러가 있으며이를 위해 내비게이션 컨트롤러를 사용하고 있습니다. 지금 내가 뭘 하려는지 : 하나의보기 컨트롤러를 입력에서 다른 UIAlertView 상자가 온다 "아니오"를 클릭하면, 그것은보기 컨트롤러를 팝업하고 이전 하나로 이동해야합니다. PopToViewController 시도 : 애니메이션 및 PopViewController : 애니메이션 있지만 그들 중 누구도 일하고있다. 그게 가능하다면 누가 말해 줄 수 있니? 그렇다면 어떻게?UIAlertView Alert에서 팝업 뷰보기

경고 상자에서 "아니요"를 누르고 있지만보기가 팝업되지 않으면 콘솔에 아무 것도 인쇄 할 수 있습니다. 어떤 제안?

감사 비크

+0

설정 애니메이션 매개 변수 전무 NO에있을 것입니다 다음 –

답변

0

대답은 (만 밀어 수/팝 컨트롤러) "보기"에 의해 당신이 UIViewController에 언급하는 것으로 가정 그리고 당신은 네비게이션 컨트롤러의 pushViewController:animated: 선택하여이 컨트롤러를 호출하는 것을 .

그런 다음 .H 파일

@interface MyController : UIViewController <UIAlertViewDelegate> { 

} 

@end 

당신이 당신의 컨트롤러 UIAlertViewDelegate을 구현해야 감안할 때, 당신이 예에서 UIAlertView

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"No", nil]; 

[alert show]; 
[alert release]; 

을 만들 때 제대로 버튼의 인덱스를 확인해야합니다 위의 경우 "OK"버튼은 인덱스 0이고 "No"버튼은 인덱스 1입니다. 따라서 alertview:clickedButtonAtIndex: 대리자 메소드를 구현할 때 사용자가 오른쪽 버튼을 누른 다음 컨트롤러 팝 액션을 수행 할 수 있는지 확인할 수 있습니다.

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    if (buttonIndex == 1) { //button NO licked 
     [self.navigationController popViewControllerAnimated:YES]; 
    } 

} 

편집 :

당신이 인스턴스를 확인하여 UINavigationController, 그렇지 않으면 컨트롤러 navigationController 속성은

tabBarController = [[UITabBarController alloc] init]; 
tabBarController.view.frame = CGRectMake(0, 0, 320, 460); 
NSMutableArray *controllers = [[NSMutableArray alloc] initWithCapacity:1]; 
ownerController *oController = [[ownerController alloc] init]; 

//navigation controller creation 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: oController]; 
[oController release]; 
//adds navigation controller to collection of controllers 
[controllers addObject:nav]; 

[tabBarController setViewControllers:controllers]; 
[controllers release]; 
[self.view addSubview:[tabBarController view]]; 
+0

@Felipe을 시도 - 내가 뭐하는 거지 정확히 같은 것. 콘솔에 물건을 인쇄 할 수 있지만 popViewControllerAnimated : 함수가 작동하지 않습니다. 다음은 관련 코드입니다. – Vik

+0

- (void) viewDidLoad { [super viewDidLoad]; \t self.view = [[UIView alloc] initWithFrame : [[UIScreen mainScreen] applicationFrame]]; UIAlertView * alertOwner = [[UIAlertView alloc] initWithTitle : @ "소유자입니까?" message : @ "Owner Please"델리게이트 : self cancelButtonTitle : @ "No"otherButtonTitles : @ "Yes", nil]; [alertOwner show]; [alertOwner release]; \t \t } - (무효) alertView (UIAlertView *) alertView clickedButtonAtIndex (NSInteger) buttonIndex { \t (buttonIndex == 0) { \t \t \t [self.navigationController popViewControllerAnimated : YES] 경우; \t \t } – Vik

+0

인스턴트 메시지 및이 컨트롤러를 호출하는 코드를 표시 할 수 있습니까? –