xcode 如何手动关闭UIViewController. popover演示文稿控制器

ycl3bljg  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(70)

对于iPad,当处于纵向模式时,我让我的左视图控制器(主控制器)隐藏起来,只显示它的popoverPresentationController,这很好用,但当处于横向模式时,我希望我的主控制器以全视图显示,它的popoverPresentationController隐藏起来,但这似乎不可能,我试过了

[self.masterViewController dismissViewControllerAnimated:self.masterViewController.popoverPresentationController completion:nil];

但是这并不起作用。左窗格是空的。我试着在上面的代码中删除弹出窗口后添加这两行,但左窗格上仍然没有任何内容:

[self.masterViewController dismissViewControllerAnimated:self.masterViewController.popoverPresentationController completion:nil];

有人知道如何像用户在弹出窗口外单击一样手动关闭弹出窗口PresentationController吗?

a64a0gku

a64a0gku1#

我在父视图控制器中使用以下代码:

IdentifyDeviceViewController *vc=[[IdentifyDeviceViewController alloc]init];    
vc.modalPresentationStyle=UIModalPresentationPopover;
vc.preferredContentSize = CGSizeMake(414, 672);    vc.popoverPresentationController.sourceRect=CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+190, 0, 0);
vc.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
vc.popoverPresentationController.sourceView=self.view;
vc.popoverPresentationController.delegate=self;
[self.navigationController presentViewController:vc animated:YES completion:nil];

然后在IdentifyDeviceViewController中使用此代码进行backTap:

- (void)backTap {
    [self.popoverPresentationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}

相关问题