Instance Method

presentControllerWithName:context:

Presents a single interface controller modally.

Declaration

- (void)presentControllerWithName:(NSString *)name context:(id)context;

Parameters

name

The name of the interface controller you want to display. In your storyboard, the name of an interface controller is stored in the object’s Identifier property, which is located in the attributes inspector. This parameter must not be nil.

context

An object to pass to the new interface controller. Use the object in this parameter to communicate important information to the new interface controller, such as the data to display or any relevant state information. You may specify nil for this parameter, but doing so is not recommended.

Discussion

After calling this method, the WatchKit extension loads and initializes the new interface controller and animates it into position on top of the current interface controller. A modal interface slides up from the bottom of the screen and completely covers the previous interface.

The title of the modal interface is set to the string Cancel by default. Change the title using the setTitle: method. Tapping the title dismisses the interface automatically. To dismiss the interface programmatically, call the dismissController method.

Always call this method from your WatchKit extension’s main thread.

See Also

Presenting Interface Controllers Modally

presentControllerWithNames:contexts:

Presents a page-based interface modally.

presentAlertControllerWithTitle:message:preferredStyle:actions:

Presents an alert or action sheet over the current interface controller.

WKAlertControllerStyle

Constants indicating the styles for standard system alerts.

dismissController

Dismisses the current interface controller from the screen.