2012-08-27 1 views
0

집보기가 있습니다. 다른보기로 다시 이동합니다. 다른보기로 이동할 것입니다.보기에서 단추를 클릭하면 모달보기가 나타나고 이후에는 3 차례 더 표시됩니다. 모달보기를 클릭 할 때 각 모달보기를 클릭하십시오. 마지막 모달보기를 클릭하면 경고가 표시되고 해당 경고를 클릭하면 루트 홈 뷰를 표시합니다. 가능합니까? ?poptorootview alerrtview를 클릭 할 때 확인

답변

0

샘플 코드는 다음과 같다 :

UIAlertView * 경고 = [:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Alert Message?" message:@"Error......" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK"] autorelease]; 
[alert show]; 

실현하는 것이의 alertView의 위임 기능이 주어진 코드를 사용하여

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) 
    { 
     //cancel clicked ...do your action 
    } 
    else if (buttonIndex == 1) 
    { 
     //OK clicked 
     [self.navigationController popToViewController animated:YES]; 
    } 
} 
+0

나는 이것을 좋아하지만 현재 뷰 자체에 머무르고있다. 루트 뷰가 아니다. –

+0

점검 편집 된 답변 –

0
int c=[self.navigationController.viewControllers count]-4; 
      [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:c] animated:YES]; 
1

디스플레이 AlertView 아래에 주어진다 [UIAlertView alloc] initWithTitle : 제목 메시지 : @ "경고 메시지" 델리게이트 : self cancelButtonTitle : @ "Ok"otherButtonTitles : nil]; [경고 표시]; [alert release];

대표 구현 방법 :

  • (무효) alertView (UIAlertView *) alertView clickedButtonAtIndex (NSInteger) buttonIndex {[self.navigationController popToRootViewControllerAnimated : YES];

}

0

그냥 alertview 쓰기를 넣고 코드의 대리자 메서드에서 .H 파일과 후 대리자를 제공합니다 ..

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ 
    if (buttonIndex == 1) { 
      [self.navigationController popToRootViewControllerAnimated:YES];///this line is important.. 
    } 
    else{ 
     // do your action... 
    } 
} 

난 ..이 답변이 당신에게 유용 희망

:)

+0

nooooooo가 작동하지 않음 –

+0

homeviewcontroller에서 모든보기를 푸시 ?? 또한 간단한 UIButton 클릭 이벤트에서이 코드를 먼저 시도해보십시오. ... –

+0

put [self.navigationController popToRootViewControllerAnimated : YES]; 위 라인의 메소드에서이 라인을 ... 또는 buttonindex == 1에서 buttonindex == 0으로 조건을 변경하십시오. –

관련 문제