为什么Xcode Playground通过类似iPad的模拟器执行liveView?

kei*_*092 19 xcode ipad ios swift swift-playground

在此输入图像描述

我正在使用Swift 3在Xcode 8.2.1 Playground中尝试一些代码.
自从PlaygroundPage.current.liveView执行类似iPad的模拟器以来,我一直很困惑.
我想通过较小设备的模拟器测试键盘输入.我能更好地处理这件事吗?

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        setupTextView()
    }

    private func setupTextView() {
        let textView = UITextView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
        textView.backgroundColor = .gray
        textView.isSelectable = true
        textView.font = textView.font?.withSize(20)
        view.addSubview(textView)
    }

}

let viewController = ViewController()
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 640, height: 600))
window.rootViewController = viewController
window.makeKeyAndVisible()

import PlaygroundSupport

PlaygroundPage.current.liveView = window
PlaygroundPage.current.needsIndefiniteExecution = true
Run Code Online (Sandbox Code Playgroud)

ben*_*enc -1

它可能与“ Swift Playgrounds ”应用程序有关?

该应用程序仅适用于 iPad(您甚至无法在 iPhone 上的 App Store 中找到它)。