Xcode Swift Playgrounds - 如何为 ViewController 设置默认大小

Xcode Swift Playgrounds - How to make default size for ViewController

我有一个在 Mac 上构建的游乐场,但也打算在 iPad 版本上使用。我有一个 UIViewController,我在上面显示我的所有内容。在 iPad 游乐场上,这个 ViewController 会自动调整到实时取景区域。这就是我要的。尽管在计算机上,UIViewController(以编程方式创建)仅占用 iPhone 7 的 space。我想要一个 iPad 大小的区域,以便我可以测试我的更大范围内的内容。我该怎么做(例如:为 Xcode 设置默认大小,但保持 iPad 的行为)。

谢谢,

今天就 运行 讨论这个问题。您必须设置 UIViewController 的 preferredContentSize。

viewController.preferredContentSize = viewController.view.frame.size