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

标签 ios swift swift-playground

我有一个在 Mac 上构建的 Playground ,但也打算在 iPad 版本上使用。我有一个 UIViewController,我在上面显示我的所有内容。在 iPad Playground 上,此 ViewController 会自动调整大小以适应实时 View 的区域。这就是我要的。尽管在计算机上,UIViewController(以编程方式创建)仅占用 iPhone 7 的空间。我想要一个 iPad 大小的区域,以便我可以在更大的范围内测试我的内容。我将如何着手执行此操作(例如:为 Xcode 设置默认大小,但在 iPad 上保持该行为)。

谢谢,

最佳答案

今天刚遇到这个问题。您必须设置 UIViewController 的 preferredContentSize。

viewController.preferredContentSize = viewController.view.frame.size

关于ios - Xcode Swift Playgrounds - 如何为 ViewController 设置默认大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42731237/

相关文章:

ios - 默认情况下,MPMoviePlayerController View 应自动向右横向旋转

ios - 从子模块引用 pod 时“没有这样的模块”

swift - Xcode6-Beta Swift Playground 停止解释任何项目中的命令

swift - UIImageView 动画 Playground

Swift 添加 : Execution was interrupted, 原因 : EXC_BAD_INSTRUCTION (Code=EXC_l386_INVOP, subcode=0x0)

ios - secureTextEntry 不工作

ios - 您的二进制文件未针对 iPhone 5 进行优化

iOS:UIViewController 未被推送问题

ios - 以编程方式设置 IOS 辅助功能颜色反转

ios - Swift - 使用 animateWithDuration 淡化 CAGradientLayer