Formsheet ios 8约束与iphones约束相同 [英] Formsheet ios 8 constraints are same as iphones constraints

查看:115
本文介绍了Formsheet ios 8约束与iphones约束相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这个问题,其中ios 8中的表格采用为compact-width regular -height(即所有iPhone约束)而不是any-any或regular -width regular -height设置的约束。
我有两种不同的iPhone和iPad设计,因为表格正在消耗iPhone限制iam
无法达到相同的效果。任何有关这方面的帮助都将是aprreciatd

I have this problem where formsheet in ios 8 is taking the constraints set for "compact - width regular -height" (that is all iPhones constraints) instead of "any- any" or "regular -width regular -height". I have two different design for iPhone and iPad since the formsheet is consuming iPhones constraint iam not able to achieve the same. Any help on this would be aprreciatd

推荐答案

从UIViewController类引用:

From the UIViewController class reference:


在水平常规环境中,显示以屏幕为中心的内容的演示文稿样式。内容区域的宽度和高度小于屏幕尺寸,并且在内容下方放置调光视图。如果设备处于横向方向且键盘可见,则向上调整视图的位置,以使视图保持可见。所有未覆盖的区域都是灰色的,以防止用户与它们进行交互。

In a horizontally regular environment, a presentation style that displays the content centered in the screen. The width and height of the content area are smaller than the screen size and a dimming view is placed underneath the content. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.

在水平紧凑的环境中,此选项的行为与 UIModalPresentationFullScreen相同

In a horizontally compact environment, this option behaves the same as UIModalPresentationFullScreen.

因为iPad上的表单演示文稿是紧凑的宽度和常规高度,所以这些值是你要的当您提交表单时获取。

Because the form sheet presentation on iPad is compact width and regular height, these are the values you'll get when you present a form sheet.

如果您不想使用默认大小类,则可以覆盖它们。

If you don't want the default size classes you can override them.

如果你的视图控制器是另一个的子视图控制器,你可以使用 setOverrideTraitCollection(_:forChildViewController:)和覆盖子控制器的大小类约束。

If your view controller is a child view controller of another, you can use setOverrideTraitCollection(_:forChildViewController:) and override the size class constraints for the child controller.

如果你的视图控制器不是子视图控制器,你真的不应该改变特征集合,但是你可以使用此黑客攻击

If your view controller is NOT a child view controller, you're not really supposed to change the trait collection, but you can do it using this hack.

最好的解决方案是将视图控制器设计为适合于应用于表单工作表视图控制器演示的默认(正确)大小约束。您通常可以通过避免设置宽度约束并仅设置前导和尾随约束来实现此目的。

The best solution would be to design your view controller to look appropriate in the default (correct) size constraints applied for a form sheet view controller presentation. You can usually do this by avoiding setting width constraints and only setting leading and trailing constraints.

这篇关于Formsheet ios 8约束与iphones约束相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆