> For the complete documentation index, see [llms.txt](https://ios-course.cornellappdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-course.cornellappdev.com/resources/archived-past-semesters/sp23/chapters/2.-uikit-and-autolayout/lecture-demo.md).

# Lecture Demo

UIKit and Autolayout

No starter code for this lecture, but please download the image. We'll be going over how to configure your projects for [programmatic AutoLayout](/resources/archived-past-semesters/sp23/chapters/2.-uikit-and-autolayout/lecture-handout.md#what-is-autolayout). These are steps you'll have to do at the start of all of your projects.&#x20;

Here's a [cheat sheet](/resources/archived-past-semesters/sp23/cheat-sheets/setting-up-a-new-xcode-project.md#setup-for-programmatic-autolayout) going over these steps for future reference.

{% file src="/files/tveAIVIjJv30KZwqsHbu" %}

```swift
 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            let VC = ViewController()
            window.rootViewController = UINavigationController(rootViewController: VC)
            window.makeKeyAndVisible()
            self.window = window
        }
    }
```
