Xcode: Playground Live View navigation controller clipped at top

247 Views Asked by At

I am creating a playground live view of a navigation controller with a single view controller.

import UIKit
import PlaygroundSupport

final class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()

    title = "View Controller"
  }
}

let viewController = ViewController()
let navigationController = UINavigationController(rootViewController: viewController)

PlaygroundPage.current.liveView = navigationController

The expected result is to have the navigation controller fully visible. Ideally, the frame would be an iPhone size, however, it's not necessary.

However, the result is clipped in the Playground Live View. See the following screenshot.

Playground live view

Is there a workaround to this behavior? Xcode version Version 12.5

1

There are 1 best solutions below

0
Ilias Karim On

One solution is to use the navigation controller's view property. I.e.

PlaygroundPage.current.liveView = UINavigationController(rootViewController: controller).view