首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将UIModalPresentationStyle设置为iPhone 6+在景观中?

将UIModalPresentationStyle设置为iPhone 6+在景观中?
EN

Stack Overflow用户
提问于 2015-04-26 22:37:00
回答 1查看 1.4K关注 0票数 3

我希望在所有设备和所有方向上始终在弹出窗口中显示视图控制器。我试图通过采用UIPopoverPresentationControllerDelegate并设置sourceViewsourceRect来实现这一点。故事板中的segue被配置为作为Popover segue的礼物。这是非常好的工作所有的设备和方向,除了iPhone 6+在景观。在这种情况下,视图控制器在表单中从屏幕底部滑行。我怎样才能防止它总是出现在弹出框中呢?

代码语言:javascript
复制
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let popoverPresentationController = segue.destinationViewController.popoverPresentationController
    popoverPresentationController?.delegate = self
    popoverPresentationController?.sourceView = self.titleLabel!.superview
    popoverPresentationController?.sourceRect = self.titleLabel!.frame
}

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return UIModalPresentationStyle.None
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-27 13:35:19

实现新的( iOS 8.3) adaptivePresentationStyleForPresentationController:traitCollection:方法的UIAdaptivePresentationControllerDelegate

代码语言:javascript
复制
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
    // This method is called in iOS 8.3 or later regardless of trait collection, in which case use the original presentation style (UIModalPresentationNone signals no adaptation)
    return UIModalPresentationNone;
}

UIModalPresentationNone告诉演示控制器使用原始的演示样式,在您的情况下,这种样式将显示一个弹出窗口。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29884416

复制
相关文章

相似问题

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