2011-02-09 2 views

답변

0

팝업보기에서 버튼을 눌렀을 때 루트보기 컨트롤러가 먼저 팝업을 닫은 다음 루트보기 컨트롤러에서 새보기를 표시 할 수있게해야합니다.

popver 내부 버튼을 사용하여 popover의 해고하는 방법에 대한 자세한 내용은 이전 대답 "How to setup Popover views to dismiss properly"을 참조하십시오.

주요 아이디어는 : 당신이 그것에 대한 참조를 유지해야합니다

은 수동으로 팝 오버를 닫습니다. 좋은 장소는 popover를 보여주는보기 컨트롤러에있을 것입니다.

콘텐츠 뷰 컨트롤러 내부 버튼 대리자 + 프로토콜 또는 NSNotificationCenter가있는 팝 오버, 가능한 방법으로 두 를 해제합니다 ( 팝 오버를 표시) 원래 뷰 컨트롤러 말하게한다. 그 이전의 대답에


는 PresenterViewController는 루트 뷰 컨트롤러합니다 (팝 오버를 제시 한)입니다. @aBitObvious

- (void)contentFooViewControllerDone:(NSNotification *)notification 
{ 
    // Button in content view controller was tapped, dismiss popover... 
    [self.popoverController dismissPopoverAnimated:YES]; 

    // Load new view here... 
    // Note: If intending to use presentModalViewController 
    // (instead of addSubView), you might need to set animated to NO 
    // for above popover dismissal (otherwise presentModal will do nothing) 
    // or use performSelector:withObject:afterDelay to present new 
    // view controller to animate both dismiss and present. 
} 
+0

,하지만 난 UIView의를로드하는 버튼 액션 코드가 필요합니다 :

귀하의 경우의 차이는 (당신이 당신의 루트 뷰 컨트롤러에 넣어 것)을 contentFooViewControllerDone 방법에있을 것입니다 내 rootViewController를 통해. – Meeya

+0

루트보기 컨트롤러에서 팝 오버 컨트롤러를 표시하고 있습니까? 콘텐츠보기 컨트롤러에 버튼이 있습니까? IB로 또는 프로그래밍 방식으로 버튼을 만들었습니까? "버튼 액션 코드가 필요합니다"라고 묻는 질문을 잘 모릅니다. 지금까지 무엇을 얻었습니까? – Anna

+0

@aBitObvious, yes correct .. 그리고 popover에는 인터페이스 빌더에서 생성 된 UIButton이 있습니다. 그리고 버튼을 클릭하면 새로운 루트보기를 통해 uiview를 열어야합니다. pushviewcontroller 코드를 실행하려고했습니다. 그러나 성공하지 못했습니다. – Meeya

0
[[NSNotificationCenter defaultCenter] 
            addObserver:self 
            selector:@selector(contentFooViewControllerDone:) 
            name:@"contentFooViewControllerDone" 
            object:popoverController.contentViewController]; 



- (void)contentFooViewControllerDone:(NSNotification *)notification 
{ 
    // Button in content view controller was tapped, dismiss popover... 
    [self.popoverController dismissPopoverAnimated:YES]; 
} 

- (void)dealloc 
{ 
    //stop listening for notifications and release popoverController... 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    [popoverController release]; 
    [super dealloc]; 
} 

- (IBAction)dismissButtonTapped 
{ 
    [[NSNotificationCenter defaultCenter] 
        postNotificationName:@"contentFooViewControllerDone" object:self]; 
} 
관련 문제