Ios 为什么不是';你不喜欢iPhone 6 Plus使用的内容大小吗?
在我的iOS 8应用程序中,此popover segue在除iPhone 6 Plus外的所有方向的所有设备上都能正确显示: 这就是它在iPhone6plus上的外观(它几乎从上到下延伸): 当它像这样显示时,在视图外单击并不会取消它(尽管“取消”起作用)。旋转回纵向,使其恢复正常 此Ios 为什么不是';你不喜欢iPhone 6 Plus使用的内容大小吗?,ios,uiviewcontroller,iphone-6-plus,Ios,Uiviewcontroller,Iphone 6 Plus,在我的iOS 8应用程序中,此popover segue在除iPhone 6 Plus外的所有方向的所有设备上都能正确显示: 这就是它在iPhone6plus上的外观(它几乎从上到下延伸): 当它像这样显示时,在视图外单击并不会取消它(尽管“取消”起作用)。旋转回纵向,使其恢复正常 此UIViewController中的所有约束都安装在所有尺寸等级上 调试视图中的值时显示:我看到以下内容: po self.view:frame=(0;250 394) po self.preferredCo
UIViewController
中的所有约束都安装在所有尺寸等级上
调试视图中的值时显示:
我看到以下内容:
- po self.view:frame=(0;250 394)
- po self.preferredContentSize(宽=250,高=160)
UIExtField
的验证要求与UIAlertController
不兼容)
编辑以包含我的popover代码:
此代码位于prepareforsgue:
FavoriteNameViewController *nameVC = segue.destinationViewController;
UIPopoverPresentationController *popPC = nameVC.popoverPresentationController;
popPC.delegate = self;
nameVC.delegate = self;
nameVC.view.center = self.originalContentView.center;
然后是委托方法:
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
下面是Xcode中的segue定义:
你看到的不是一件府绸。这是一个正常的视图。默认情况下,popover在iPad上显示为popover,但在iPhone上显示为显示视图,包括iPhone 6 plus。在其他iPhone上,这个视图是全屏的——它涵盖了一切。但是iPhone 6是如此之大,以至于他们不这样做,所以它出现在屏幕中间的一个标准宽度(一个较小的iPhone的宽度)。 因此,优选内容大小没有影响。这不是爆米花。显示的视图控制器视图都有一个标准大小,这一个也不例外 但是,您可以让popover在iPhone上显示为popover。为此:
- 在显示popover视图控制器之前,为其设置一个代理
PopoOverPresentationController
- 在委托中,为PresentationController实现
并返回自适应PresentationStyle:
。无
adaptivePresentationStyleForPresentationController:traitCollection:
返回。无
,您将在任何情况下都能获得一个popover,包括横向中的iPhone 6 Plus。下面是一个完整的工作示例,其中popover在代码中创建和调用,以响应按钮点击:
@IBAction func doButton(sender: AnyObject) {
let vc = MyViewController()
vc.preferredContentSize = CGSizeMake(400,500)
vc.modalPresentationStyle = .Popover
if let pres = vc.presentationController {
pres.delegate = self
}
self.presentViewController(vc, animated: true, completion: nil)
if let pop = vc.popoverPresentationController {
pop.sourceView = (sender as! UIView)
pop.sourceRect = (sender as! UIView).bounds
}
}
func adaptivePresentationStyleForPresentationController(
controller: UIPresentationController,
traitCollection: UITraitCollection)
-> UIModalPresentationStyle {
return .None
}
根据我添加的编辑,听起来我已经在做你建议的事情了。是否调用了委托方法?是的。我刚刚在调试中确认了它。我做了很多测试,我想你已经发现了一个bug。如果您太忙而无法向苹果报告,请告诉我;如果你愿意,我会做的。请仔细阅读我说的话。仔细看我的代码。请注意,我所说的解决问题的方法,
adaptivePresentationStyleForPresentationController:traitCollection:
,与代码显示您以前实现的旧的adaptivePresentationStyleForPresentationController:
不同。它的行为完全不同。它解决了问题,我的屏幕截图证明了这一点。