Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么不是';你不喜欢iPhone 6 Plus使用的内容大小吗?_Ios_Uiviewcontroller_Iphone 6 Plus - Fatal编程技术网

Ios 为什么不是';你不喜欢iPhone 6 Plus使用的内容大小吗?

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

在我的iOS 8应用程序中,此popover segue在除iPhone 6 Plus外的所有方向的所有设备上都能正确显示:

这就是它在iPhone6plus上的外观(它几乎从上到下延伸):

当它像这样显示时,在视图外单击并不会取消它(尽管“取消”起作用)。旋转回纵向,使其恢复正常

UIViewController
中的所有约束都安装在所有尺寸等级上

调试
视图中的值时显示:
我看到以下内容:

  • po self.view:frame=(0;250 394)
  • po self.preferredContentSize(宽=250,高=160)
是什么导致视图的高度跳到394

事实上,我对iPhone6Plus中的另一款popover segue也有同样的问题。(出于好奇,我在这里使用VC而不是“UIAlertController”,因为显示的
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:
    并返回
    。无

然而,这显然不适用于iPhone 6 Plus的横向模式;popover没有“适应”。我会把它描述成一个bug

编辑在iOS 9中,问题解决了!实现新的委托方法
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:
不同。它的行为完全不同。它解决了问题,我的屏幕截图证明了这一点。