2016-07-08 7 views
1

정적 데이터를 표시하는 UIPopoverPresentationcontroller을 표시하는 곳에서 viewControllerA가 있습니다. 자세한 내용은 아래 코드를 참조하십시오. 이 자동으로 기각 될 때 단순히보기에 만졌을 때 나는 "팝업"보기를 기각에 대한 코드를 작성하지 않은 것처럼닫을 때 UIPopoverPresentationController 이벤트 가져 오기

- (void)openPopupScreen:(id)sender { 

    PopupViewController *popupVC = [self.storyboard instantiateViewControllerWithIdentifier:@"popupViewController"]; 
    popupVC.delegate = self; 
    popupVC.preferredContentSize = CGSizeMake(220.0f, 230.0f); 
    popupVC.modalPresentationStyle = UIModalPresentationPopover; 
    _popupView = popupVC.popoverPresentationController; 
    self.popupView.delegate = self; 
    self.popupView.sourceView = self.view; 
    self.popupView.backgroundColor = [UIColor whiteColor]; 
    CGRect rect = CGRectMake(0.0f, 0.0f, 220.0f, 230.0f);   
    self.popupView.sourceRect = rect; 
    [self presentViewController:popupVC animated:YES completion:nil]; 
} 

.

제 질문은 팝업이 해제되었을 때 이벤트가 필요하다는 것입니다.

미리 감사드립니다.

답변

2

이미 아래 문 UIPopoverPresentationControllerDelegate의 대리자를 적용했듯이. UIPopoverPresentationControllerDelegate 방법

self.popupView.delegate = self; 

목록.

1) Popover 컨트롤러가 Popover를 닫을 때 대리자에서 호출됩니다. //보기 해지를 방지하려면 NO를 반환합니다.

- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController; 

2) 사용자가 팝업을 닫으려는 작업을 수행 할 때 대리인에 의해 호출됩니다. popover가 프로그램 적으로 제한 될 때 호출되지 않습니다.

- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController; 

3) 대리인에게 팝업이 표시 될 예정임을 알립니다.

- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController; 

자세한 내용은 Apple Developer link을 확인하시기 바랍니다.

참조 용으로 팝업을 닫을 때 popoverPresentationControllerDidDismissPopover이 호출됩니다.

희망은 당신을 위해 작동합니다.

0

UIPopoverPresentationControllerDelegatepopoverPresentationControllerDidDismissPopover 방법에서 찾으십시오.

+0

답변 해 주셔서 감사합니다. – Nikita

0

시도의 UIPopoverControllerDelegate 방법

- (void) popoverControllerDidDismissPopover:(UIPopoverController *) popoverController { 
    //do stuff here... 
} 
+0

답변 해 주셔서 감사합니다. – Nikita

관련 문제