Ilias Karim
Ilias Karim

Reputation: 5371

Xcode: Playground Live View navigation controller clipped at top

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

Upvotes: 0

Views: 272

Answers (1)

Ilias Karim
Ilias Karim

Reputation: 5371

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

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

Upvotes: 0

Related Questions