2012-05-13 1 views
0

탐색 다시 이동 확인 보기 A로 다시 이동하십시오., 나는 탐색을 확인하기 위해 UIActionSheet을 사용자에게 현재 시도하고 난 뒤로 UIBarButtonItem을 눌러시 B.</p> <p>보기로 이동합니다 모양 A를 엑스 코드를 사용하여보기

보기에서 뒤로 이동하지 않도록하려면 코드에서 수행해야하는 작업 (사용자 입력에 따라 다름)으로 이동하거나 현재 화면에 머물러 있어야합니까?

답변

8

프로그래밍 방식으로 백 버튼을 추가하십시오.

예 :

UIButton *backBtn= [[UIButton alloc] initWithFrame:CGRectMake(0,0,54,30)]; 
[backBtn addTarget:self action:@selector(backButtonPressed:)forControlEvents:UIControlEventTouchUpInside]; 
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; 
[backBtn release]; 
[[self navigationItem] setLeftBarButtonItem:backBarButton]; 
[backBarButton release]; 

    //backButtonPressed is the selector for backBtn 

그럼 당신은 이전의 ViewController로 이동 또는 해달라고 선택에서 ActionSheet 및 사용자에 따라 중 하나를 제시한다.

이전 페이지로 이동하려면 popViewMethod를 사용하십시오.

`

+0

"popToRootViewControllerAnimated"뿐만 아니라 "backButtonPressed :"메서드도 구현했지만 UIBarButton은 보이지 않습니다. – Demasterpl

1

당신은 다른 모든 action.It에 존재하지 UIActionSheet이 목적을 위해 UIAlertView를 사용하는 것이 좋을 것이다합니다. Apple UIActionsheet Guidelines에 따라 : -

작업을 완료하는 다른 방법을 제공하십시오. 활동 시트를 사용하면 사용자 인터페이스에서 이러한 선택 사항을 영구히 두지 않고 현재 태스크의 컨텍스트에서 의미가있는 다양한 선택 사항을 제공 할 수 있습니다.

잠재적으로 위험한 작업을 완료하기 전에 확인하십시오. 액션 시트는 사용자에게 그들이 취할 단계의 잠재적으로 위험한 영향에 대해 생각하게하고 몇 가지 대안을 제시합니다. 이러한 유형의 통신은 iOS 기반 장치에서 특히 중요합니다. 사용자가 의미없는 제어를 탭하기 때문입니다. UIAlertView에 대한

: -

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert View" 
                  message:@"Do You want to go back to previous screen?" 
                  delegate:self 
               cancelButtonTitle:@"NO" 
               otherButtonTitles:@"YES",nil]; 
[alertView show]; 
[alertView release]; 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) { 
     NSLog(@"THE 'NO' BUTTON WAS PRESSED"); 
    } 
    if (buttonIndex == 1) { 
     NSLog(@"THE 'YES' BUTTON WAS PRESSED"); 
    } 
} 

을 누르면 버튼에 UINavigationController.According의 뒤로 버튼의 동작에 구현 "예"또는 "아니오", 당신은 UIAlerrtVIewDelegate 프로토콜을 준수 navigation.Also 할 수 있습니다.