Ios UIPopoverPresentationController是popoverVisible

Ios UIPopoverPresentationController是popoverVisible,ios,objective-c,Ios,Objective C,我正在使用UIPopoverPresentationController并分配对象,如以下代码所示 UIPopoverPresentationController *presentationController = [myPopoverViewController popoverPresentationController]; 我只想检查popover是否在另一个方法中可见。之前在UIPopoverController中有popoverVisible可用,是否有其他替代方案。?我还想

我正在使用UIPopoverPresentationController并分配对象,如以下代码所示

UIPopoverPresentationController *presentationController =
     [myPopoverViewController popoverPresentationController];
我只想检查popover是否在另一个方法中可见。之前在UIPopoverController中有popoverVisible可用,是否有其他替代方案。?我还想用其他方法消除它,有没有其他方法可以消除过度动画化。? 我只想做这样的事

if (presentationController != nil && presentationController.popoverVisible)
    {
        [presentationController dismissPopoverAnimated:YES];
    }
谢谢你的帮助

谢谢你试试这个

  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
 }
有关示例,请参见此

  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
 }

有关此示例,请参见所有
UIViewController
现在都有一个
isBeingPresented
属性,因此,与其尝试检查
UIPopoverPresentationController
是否处于活动状态,不如检查
myPopoverViewController

if myPopoverViewController.isBeingPresented {
    myPopoverViewController.dismiss(animated: true, completion: nil)
}

所有
UIViewController
s现在都有一个
isBeingPresented
属性,因此与其尝试检查
UIPopoverPresentationController
是否处于活动状态,不如检查
myPopoverViewController

if myPopoverViewController.isBeingPresented {
    myPopoverViewController.dismiss(animated: true, completion: nil)
}

UIPopoverPresentationController没有dismissViewControllerAnimated,我尝试了self,但我正在使用UIPopoverPresentationController的编号,因此它会变得混乱,我只想检查UIPopoverPresentationController对象是否已可见。UIPopoverPresentationController没有dismissViewControllerAnimated,我尝试了self,但我正在使用UIPopoverPresentationController的编号,因此它会变得混乱,我只想检查UIPopoverPresentationController对象是否已经可见。
UIPopoverPresentationController
不是
UIViewController
子类。@svilansky,请澄清这一点。是的,你提到的两种类型是不同的。然而,@jjatie说你可以检查
myPopoverViewController.isBeingPresented
,因为
myPopoverViewController
是一个
UIViewController
。嘿,如果我错了,请纠正,但我认为只要popover的出现过程正在发生,isBeingPresented就是正确的。动画完成的时刻isBeingPresented设置为false。所以它并没有真正取代popoverVisible属性:(有人解决了这个问题吗?谢谢
UIPopoverPresentationController
不是
UIViewController
子类。@斯维兰斯基,请澄清这一点。是的,你提到的这两种类型是不同的。但是,@jjatie说你可以检查
myPopoverViewController。之所以呈现是因为
myPopoverViewController
是一个
UIViewController
。嘿,如果我错了,请更正,但我认为只要出现popover的过程正在进行,isBeingPresented就是正确的。动画完成的时刻isBeingPresented设置为false。因此,它不会真正替换popoverVisible属性:(有人解决了这个问题吗?谢谢