2

iPhone MP 영화 플레이어 컨트롤러의 샘플 응용 프로그램을 보았습니다.아이폰 애플리케이션에서 팝업 뷰 컨트롤러에 대한 알림을 추가하는 방법은 무엇입니까?

그들은 샘플 코드에 대한 알림을 추가했습니다.

// Register to receive a notification that the movie is now in memory and ready to play 
[[NSNotificationCenter defaultCenter] addObserver:self 
       selector:@selector(moviePreloadDidFinish:) 
       name:MPMoviePlayerContentPreloadDidFinishNotification 
       object:nil]; 

위 코드에서 MPMoviePlayerController가로드를 완료하면 moviePreloadDidFinish 메서드가 호출됩니다.

마찬가지로 사용자가 내비게이션 막대에서 뒤로 버튼을 누르면 (내비게이션 컨트롤러를 통해 이전보기 컨트롤러로 돌아 가기) 메소드를 실행하고 싶습니다.

알림을 추가하는 방법을 모르겠습니다.

가능한 경우 나에게 지침을주십시오.

도와 주셔서 미리 감사드립니다.

Sagar. 의 ViewController를, 당신의 ViewController의 goBack 방법

UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithImage:yourImage style:UIBarButtonItemStyleBordered target:self action:@selector(goBack)]; 
self.navigationItem.leftBarButtonItem = btn; 
[btn release]; 

을 당신은 당신이 필요로하는 어떤 코드를 넣고 팝업 있습니다 :

+0

View-Will-Appear & View-Will-Disappear가 작동하지 않습니다. 때문에 탭 표시 줄 컨트롤러에서 여러 UINavigation 컨트롤러를 사용하고 있습니다. –

답변

6

navigationItem에서 뒤로 버튼을 사용자 정의를 넣어

- (void)goBack { 
/* your code here */ 

[self.view.navigationController popToRootViewControllerAnimated:YES]; 
} 
+1

내 고유 코드 추가를 참조하십시오. –

0

내비게이션 컨트롤러의 뒤로 숨겨진 버튼을 설정했습니다.

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    UIBarButtonItem *x=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(gotoPreviousView)]; 
    UINavigationItem *y=self.navigationItem; 
    y.hidesBackButton=YES; 
    y.leftBarButtonItem=x; 
    [x release]; 
} 

-(void)gotoPreviousView{ 
    MyAccountViewCtr *x=(MyAccountViewCtr*)[self.navigationController.viewControllers objectAtIndex:0]; 
    [self.navigationController popViewControllerAnimated:YES]; 
    [x refreshItems]; 
} 
관련 문제