首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIPopoverPresentationController是popoverVisible

UIPopoverPresentationController是popoverVisible
EN

Stack Overflow用户
提问于 2016-03-22 06:38:12
回答 2查看 1.4K关注 0票数 0

我正在使用一个UIPopoverPresentationController并像下面的代码那样分配对象,

代码语言:javascript
复制
UIPopoverPresentationController *presentationController =
     [myPopoverViewController popoverPresentationController];

我只想检查在另一种方法中是否可以看到弹出器。在UIPopoverController的早期,popoverVisible是可用的,有什么替代办法吗?另外,我想在其他一些方法中驳回它,对于dismissPopoverAnimated有什么替代办法吗?我只想做这样的事

代码语言:javascript
复制
if (presentationController != nil && presentationController.popoverVisible)
    {
        [presentationController dismissPopoverAnimated:YES];
    }

任何帮助都很感激。

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-22 06:52:57

尝尝这个

设似

代码语言:javascript
复制
  popoverPresentationController.delegate = self;

 [presentationController dismissViewControllerAnimated:YES completion:nil]; // or use self

的委托方法。

代码语言:javascript
复制
# 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
 }

有关示例,请参阅此教程

票数 1
EN

Stack Overflow用户

发布于 2017-05-31 10:49:06

所有UIViewController现在都有一个isBeingPresented属性,所以不要尝试检查UIPopoverPresentationController是否是活动的,只需检查myPopoverViewController

代码语言:javascript
复制
if myPopoverViewController.isBeingPresented {
    myPopoverViewController.dismiss(animated: true, completion: nil)
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36147702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档