有没有人知道UIPopoverPresentationController
是否可以用来在iPhones上呈现弹出画面?想知道苹果是否在iOS 8上添加了这一功能,试图为iPad和iPhone创建更统一的呈现控制器。
不确定是否可以问/回答测试版的问题。在这种情况下,我会删除它。
发布于 2015-08-12 20:41:52
确保实现UIAdaptivePresentationControllerDelegate
如下所示:
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
如果您不想要全屏弹出窗口
发布于 2014-12-20 17:15:39
我找到了一些解决方法。
在Xcode6.1上,使用presentationController.delegate
而不是popoverPresentationController.delegate
。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier compare:@"showPopOver"] == NSOrderedSame) {
UINavigationController * nvc = segue.destinationViewController;
UIPresentationController * pc = nvc.presentationController;
pc.delegate = self;
}
}
#pragma mark == UIPopoverPresentationControllerDelegate ==
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationNone;
}
在WWDC2014“在iOS8中查看控制器的改进”中,下面的代码可以在iPhone上显示弹出窗口。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UINavigationController * nvc = segue.destinationViewController;
UIPopoverPresentationController * pvc = nvc.popoverPresentationController;
pvc.delegate = self;
}
#pragma mark == UIPopoverPresentationControllerDelegate ==
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationNone;
}
但在Xcode6.1上,这些代码显示的是FullScreen演示...(nvc.popoverPresentationController为空)
我怀疑这可能是苹果的漏洞。
发布于 2016-12-08 05:59:00
在iOS 8.3及更高版本中,在UIPopoverPresentationControllerDelegate
协议中使用以下语法来覆盖弹出窗口的UIModalPresentationStyle
。
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
https://stackoverflow.com/questions/25319179
复制相似问题