我正在使用一个UIPopoverPresentationController并像下面的代码那样分配对象,
UIPopoverPresentationController *presentationController =
[myPopoverViewController popoverPresentationController];我只想检查在另一种方法中是否可以看到弹出器。在UIPopoverController的早期,popoverVisible是可用的,有什么替代办法吗?另外,我想在其他一些方法中驳回它,对于dismissPopoverAnimated有什么替代办法吗?我只想做这样的事
if (presentationController != nil && presentationController.popoverVisible)
{
[presentationController dismissPopoverAnimated:YES];
}任何帮助都很感激。
谢谢
发布于 2016-03-22 06:52:57
尝尝这个
设似
popoverPresentationController.delegate = self;
[presentationController dismissViewControllerAnimated:YES completion:nil]; // or use self的委托方法。
# pragma mark - Popover Presentation Controller Delegate
- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
// called when a Popover is dismissed
}
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
// return YES if the Popover should be dismissed
// return NO if the Popover should not be dismissed
return YES;
}
- (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView *__autoreleasing _Nonnull *)view {
// called when the Popover changes position
}有关示例,请参阅此教程
发布于 2017-05-31 10:49:06
所有UIViewController现在都有一个isBeingPresented属性,所以不要尝试检查UIPopoverPresentationController是否是活动的,只需检查myPopoverViewController。
if myPopoverViewController.isBeingPresented {
myPopoverViewController.dismiss(animated: true, completion: nil)
}https://stackoverflow.com/questions/36147702
复制相似问题