---
title: WKInterfaceController
framework: watchkit
role: symbol
role_heading: Class
path: watchkit/wkinterfacecontroller
---

# WKInterfaceController

A class that provides the infrastructure for managing the interface in a watchOS app.

## Declaration

```swift
@MainActor class WKInterfaceController
```

## Overview

Overview An interface controller serves the same purpose as a UIViewController object in a UIKit app, except that it doesn’t manage any actual views. It runs in your WatchKit extension and remotely manages the behavior associated with an interface controller in your Watch app’s storyboard file. You subclass WKInterfaceController and use its methods to configure the elements of your storyboard scene and to respond to interactions with those elements. Your interface controller code runs locally on the user’s Apple Watch but is separate from the interface that it manages. When you change the value of an interface object in your code, the system forwards the needed information to your Watch app, which makes the corresponding changes onscreen. Initialize your interface controllers When the user interacts with your app content, the system launches your extension and creates the appropriate interface controller objects automatically. Apps use different interface controllers to manage their notification and app interfaces; WatchKit uses the information in your app’s main storyboard file to determine which interface controller to load. Notification scenes are configured specially so that the system can identify them. For your app, WatchKit loads your app’s main interface controller initially, but you may change the initial interface controller at launch time. When creating an interface controller, WatchKit instantiates the class and calls its init() method. You can use this method to initialize variables and load data; however, don’t use it to configure your user interface. The controller’s user interface elements may not be properly initialized when this method runs. Next, the system calls the awake(withContext:) method. If WatchKit passes a valid object to the awake(withContext:) method, use the information in that object to customize the initialization process. Also, the controller’s user interface elements are guaranteed to be available at this point. This means that you can safely use this method to configure your user interface. The willActivate() method lets you know when your interface is about to become active. Use the willActivate() method to perform any last minute tasks, such as checking for updates to your content; however, don’t use it for your primary initialization. The willActivate() method may be called at times when your interface isn’t yet onscreen. For example, WatchKit may call the method in advance so that you have time to update your content. WatchKit calls the didAppear() method to let you know when your interface becomes visible. Similarly, WatchKit calls the willDisappear() and didDeactivate() methods when your interface moves offscreen again. important: An interface controller can make changes to its interface only in the awake(withContext:) method, in the willActivate() method, and while the interface is active. Once the system calls the didDeactivate() method, it ignores any attempts to change the value of the controller’s interface objects until the system calls the interface controller’s willActivate() method again. In iOS Simulator, WatchKit calls the didDeactivate() method for the current interface controller when you lock the simulator by selecting Hardware > Lock. When you subsequently unlock the simulator, WatchKit calls that interface controller’s willActivate() method again. You can use this capability to debug your activation and deactivation code. Interface Builder configuration options Xcode lets you configure information about your interface controller in your storyboard file. The following table lists the attributes you can configure in your storyboard and their meaning.  |   |   |   |   |   |   |   |   |   |   |   |   |   |  Subclassing notes Subclass WKInterfaceController when you have a storyboard scene that requires configuration at runtime or that handles user interactions. Typically, you define a custom subclass for each unique storyboard scene that your app manages. In your subclass, define outlets for any interface objects you need to configure and define action methods for responding to interactions with the elements of your storyboard scene. Most custom interface controllers you use in your app require a custom interface controller subclass. Even glances need an interface controller to update the glance contents. The only storyboard scene that can’t use a custom interface controller is the scene associated with a static notification interface. When implementing an interface controller for your dynamic notification interface, subclass WKUserNotificationInterfaceController instead. Override any methods of the class needed to configure your interface and get it ready to display. Most interface controllers override the init() and awake(withContext:) methods. Override any other methods that make sense based on your needs.

## Topics

### Creating the interface controller

- [init()](watchkit/wkinterfacecontroller/init().md)
- [awake(withContext:)](watchkit/wkinterfacecontroller/awake(withcontext:).md)
- [setTitle(_:)](watchkit/wkinterfacecontroller/settitle(_:).md)

### Responding to activation and appearance events

- [willActivate()](watchkit/wkinterfacecontroller/willactivate().md)
- [didDeactivate()](watchkit/wkinterfacecontroller/diddeactivate().md)
- [didAppear()](watchkit/wkinterfacecontroller/didappear().md)
- [willDisappear()](watchkit/wkinterfacecontroller/willdisappear().md)

### Implementing a navigation interface

- [pushController(withName:context:)](watchkit/wkinterfacecontroller/pushcontroller(withname:context:).md)
- [pop()](watchkit/wkinterfacecontroller/pop().md)
- [popToRootController()](watchkit/wkinterfacecontroller/poptorootcontroller().md)

### Presenting interface controllers modally

- [presentController(withName:context:)](watchkit/wkinterfacecontroller/presentcontroller(withname:context:).md)
- [presentController(withNames:contexts:)](watchkit/wkinterfacecontroller/presentcontroller(withnames:contexts:).md)
- [presentController(withNamesAndContexts:)](watchkit/wkinterfacecontroller/presentcontroller(withnamesandcontexts:).md)
- [presentAlert(withTitle:message:preferredStyle:actions:)](watchkit/wkinterfacecontroller/presentalert(withtitle:message:preferredstyle:actions:).md)
- [WKAlertControllerStyle](watchkit/wkalertcontrollerstyle.md)
- [dismiss()](watchkit/wkinterfacecontroller/dismiss().md)

### Navigating a page-based interface

- [reloadRootPageControllers(withNames:contexts:orientation:pageIndex:)](watchkit/wkinterfacecontroller/reloadrootpagecontrollers(withnames:contexts:orientation:pageindex:).md)
- [WKPageOrientation](watchkit/wkpageorientation.md)
- [reloadRootControllers(withNamesAndContexts:)](watchkit/wkinterfacecontroller/reloadrootcontrollers(withnamesandcontexts:).md)
- [becomeCurrentPage()](watchkit/wkinterfacecontroller/becomecurrentpage().md)

### Managing segue-based transitions

- [contextForSegue(withIdentifier:)](watchkit/wkinterfacecontroller/contextforsegue(withidentifier:).md)
- [contextsForSegue(withIdentifier:)](watchkit/wkinterfacecontroller/contextsforsegue(withidentifier:).md)
- [contextForSegue(withIdentifier:in:rowIndex:)](watchkit/wkinterfacecontroller/contextforsegue(withidentifier:in:rowindex:).md)
- [contextsForSegue(withIdentifier:in:rowIndex:)](watchkit/wkinterfacecontroller/contextsforsegue(withidentifier:in:rowindex:).md)

### Managing Scrolling

- [scroll(to:at:animated:)](watchkit/wkinterfacecontroller/scroll(to:at:animated:).md)
- [WKInterfaceScrollPosition](watchkit/wkinterfacescrollposition.md)
- [interfaceDidScrollToTop()](watchkit/wkinterfacecontroller/interfacedidscrolltotop().md)
- [interfaceOffsetDidScrollToTop()](watchkit/wkinterfacecontroller/interfaceoffsetdidscrolltotop().md)
- [interfaceOffsetDidScrollToBottom()](watchkit/wkinterfacecontroller/interfaceoffsetdidscrolltobottom().md)
- [isTableScrollingHapticFeedbackEnabled](watchkit/wkinterfacecontroller/istablescrollinghapticfeedbackenabled.md)

### Respecting safe areas and layout margins

- [contentSafeAreaInsets](watchkit/wkinterfacecontroller/contentsafeareainsets.md)
- [systemMinimumLayoutMargins](watchkit/wkinterfacecontroller/systemminimumlayoutmargins.md)
- [contentFrame](watchkit/wkinterfacecontroller/contentframe.md)

### Animating changes to the interface

- [animate(withDuration:animations:)](watchkit/wkinterfacecontroller/animate(withduration:animations:).md)

### Handling text input

- [presentTextInputController(withSuggestions:allowedInputMode:completion:)](watchkit/wkinterfacecontroller/presenttextinputcontroller(withsuggestions:allowedinputmode:completion:).md)
- [presentTextInputControllerWithSuggestions(forLanguage:allowedInputMode:completion:)](watchkit/wkinterfacecontroller/presenttextinputcontrollerwithsuggestions(forlanguage:allowedinputmode:completion:).md)
- [dismissTextInputController()](watchkit/wkinterfacecontroller/dismisstextinputcontroller().md)
- [WKTextInputMode](watchkit/wktextinputmode.md)

### Presenting video and audio interfaces

- [presentMediaPlayerController(with:options:completion:)](watchkit/wkinterfacecontroller/presentmediaplayercontroller(with:options:completion:).md)
- [Media Player Options](watchkit/media-player-options.md)
- [dismissMediaPlayerController()](watchkit/wkinterfacecontroller/dismissmediaplayercontroller().md)
- [presentAudioRecorderController(withOutputURL:preset:options:completion:)](watchkit/wkinterfacecontroller/presentaudiorecordercontroller(withoutputurl:preset:options:completion:).md)
- [WKAudioRecorderPreset](watchkit/wkaudiorecorderpreset.md)
- [Audio Recording Options](watchkit/audio-recording-options.md)
- [dismissAudioRecorderController()](watchkit/wkinterfacecontroller/dismissaudiorecordercontroller().md)

### Handling table-row selections

- [table(_:didSelectRowAt:)](watchkit/wkinterfacecontroller/table(_:didselectrowat:).md)

### Managing pickers

- [pickerDidFocus(_:)](watchkit/wkinterfacecontroller/pickerdidfocus(_:).md)
- [pickerDidResignFocus(_:)](watchkit/wkinterfacecontroller/pickerdidresignfocus(_:).md)
- [pickerDidSettle(_:)](watchkit/wkinterfacecontroller/pickerdidsettle(_:).md)

### Getting the crown sequencer

- [crownSequencer](watchkit/wkinterfacecontroller/crownsequencer.md)

### Coordinating Handoff activity

- [update(_:)](watchkit/wkinterfacecontroller/update(_:).md)
- [invalidateUserActivity()](watchkit/wkinterfacecontroller/invalidateuseractivity().md)

### Adding PassKit passes

- [presentAddPassesController(withPasses:completion:)](watchkit/wkinterfacecontroller/presentaddpassescontroller(withpasses:completion:).md)
- [dismissAddPassesController()](watchkit/wkinterfacecontroller/dismissaddpassescontroller().md)

### Managing Notifications

- [WKAccessibilityVoiceOverStatusChanged](watchkit/wkaccessibilityvoiceoverstatuschanged.md)

### Deprecated symbols

- [Text Response Key](watchkit/text-response-key.md)
- [addMenuItem(withImageNamed:title:action:)](watchkit/wkinterfacecontroller/addmenuitem(withimagenamed:title:action:).md)
- [addMenuItem(with:title:action:)](watchkit/wkinterfacecontroller/addmenuitem(with:title:action:)-6pb4t.md)
- [addMenuItem(with:title:action:)](watchkit/wkinterfacecontroller/addmenuitem(with:title:action:)-1q2zj.md)
- [beginGlanceUpdates()](watchkit/wkinterfacecontroller/beginglanceupdates().md)
- [clearAllMenuItems()](watchkit/wkinterfacecontroller/clearallmenuitems().md)
- [endGlanceUpdates()](watchkit/wkinterfacecontroller/endglanceupdates().md)
- [handleUserActivity(_:)](watchkit/wkinterfacecontroller/handleuseractivity(_:).md)
- [presentController(_:)](watchkit/wkinterfacecontroller/presentcontroller(_:).md)
- [reloadRootControllers(withNames:contexts:)](watchkit/wkinterfacecontroller/reloadrootcontrollers(withnames:contexts:).md)
- [updateUserActivity(_:userInfo:webpageURL:)](watchkit/wkinterfacecontroller/updateuseractivity(_:userinfo:webpageurl:).md)
- [WKMenuItemIcon](watchkit/wkmenuitemicon.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [WKUserNotificationInterfaceController](watchkit/wkusernotificationinterfacecontroller.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)

## See Also

### User interface basics

- [Building watchOS app Interfaces Using the Storyboard](watchkit/building-watchos-app-interfaces-using-the-storyboard.md)
- [WKInterfaceObject](watchkit/wkinterfaceobject.md)
- [WKAlertAction](watchkit/wkalertaction.md)
- [WKAccessibilityImageRegion](watchkit/wkaccessibilityimageregion.md)
- [WKAccessibilityIsVoiceOverRunning()](watchkit/wkaccessibilityisvoiceoverrunning().md)
- [WKAccessibilityIsReduceMotionEnabled()](watchkit/wkaccessibilityisreducemotionenabled().md)
