Edit

Share via


UIViewController Class

Definition

Base class for classes that manage the interaction between Model classes and View classes

[Foundation.Register("UIViewController", true)]
public class UIViewController : UIKit.UIResponder, Foundation.INSCoding, Foundation.INSExtensionRequestHandling, IDisposable, System.Collections.IEnumerable, UIKit.IUIAppearanceContainer, UIKit.IUIContentContainer, UIKit.IUIFocusEnvironment, UIKit.IUITraitEnvironment
type UIViewController = class
    inherit UIResponder
    interface IEnumerable
    interface INSCoding
    interface INativeObject
    interface IDisposable
    interface INSExtensionRequestHandling
    interface IUIAppearanceContainer
    interface IUIContentContainer
    interface IUIFocusEnvironment
    interface IUITraitEnvironment
Inheritance
UIViewController
Derived
Attributes
Implements

Remarks

The UIViewController class is the base class of the View Controller hierarchy. View Controllers manage UIViews and other UIViewControllers. An iOS application has a single window, but many screens, each of which may contain several UIViews. Managing those screens is complex and requires responding to both user input and changes in the model (problem domain). This management and coordination is the job of the UIViewController.

A UIViewController has 3 major responsibilities:

  • Layout out its component UIViews. This includes sizing, responding to orientation changes, etc.:
  • Restructure the display in response to input events or the state of Model classes:
  • Translate user input into platform-neutral Model service requests:

iOS provides a number of standard view controllers such as UINavigationController, UITabBarController, and UIPageViewController. In general, the application developer should prefer to use standard view controllers to create the overall display structure. Using standard view controllers provides consistent, standard behavior and makes it easier for the app to conform to the iOS Human Interface Guidelines.

Additionally, the application developer generally needs to implement one or more “Content View Controllers”. These are often derived directly from UIViewController or UITableViewController. Content View Controllers are where the application developer writes the custom code to satisfy the UIViewControllers responsibilities described previously. In applications that take advantage of Xamarin Studio’s Code Behind facilities for Apple’s Interface Builder, much of this custom code will be automatically generated by Xamarin Studio. Applications written using MonoTouch.Dialog do not generally need a custom-written Content View Controller, but may use one for architectural consistency.

A single View Controller may have many views and subcontrollers, but typically a single View Controller will have a single root view and be primarily concerned with controlling that one view or it will be primarily concerned with maintaining a collection of subcontrollers. In the following example, taken from the “Hello World iPhone” sample, a Content View Controller of type HelloWorld_iPhoneViewController is instantiated and set to be the RootViewController for the application’s window:

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
       // create a new window instance based on the screen size
       window = new UIWindow (UIScreen.MainScreen.Bounds);

       viewController = new HelloWorld_iPhoneViewController ("HelloWorld_iPhoneViewController", null);
       window.RootViewController = viewController;
       window.MakeKeyAndVisible ();

       return true;
}

By contrast, the following code taken from the "iOS Standard Controls" sample demonstrates how a UITableViewController uses an application-defined NavItemGroup to manage a series of other UIViewControllers. In this code, the second parameter to the NavItem constructor is the specific UIViewController subtype desired when that item is selected in the table:

navGroup = new NavItemGroup ("Toolbars");
navItems.Add (navGroup);
navGroup.Items.Add (new NavItem ("Toolbar 1", "", typeof(Toolbar.Toolbar1_iPhone)));
navGroup.Items.Add (new NavItem ("Programmatic Toolbar", "", typeof(Toolbar.ProgrammaticToolbar_Controller)));
navGroup.Items.Add (new NavItem ("Toolbar Items", "", typeof(Toolbar.ToolbarItems)));

// create a table source from our nav items
tableSource = new NavItemTableSource (this.NavigationController, navItems);

// set the source on the table to our data source
base.TableView.Source = tableSource;

UIViewController and the MVC Architecture

The following illustration shows the classic relationship between Model, View, and Controller classes. The arrows indicate dependencies: the View depends on the Model class to provide data, the Controller depends on the Model class for information about what to display and depends on the View class to do the drawing. This diagram is idealized: there would be several classes in the Model, several Views, UIView can actually use NextResponder to determine their UIViewController, etc.

  • The Model class has no knowledge of the associated View and Controller classes. This allows the Model to evolve independently and greatly improves maintainability and portability:
  • Event handlers are used between the areas of concern. This allows for strongly-typed T:System.EventArgs that only contain the data relating to that event. This improves maintainability by limiting the client object’s access to the event-provider’s scope.:
  • The Controller reacts to events both from the View and from the Model. A UIViewController might, for instance, handle a TouchUpInside input event by requesting the Model to convert between Celsius and Fahrenheit temperature units. Conversely it might respond to a Model “too hot” event by changing the display (making visible a warning icon or somesuch). The View updates its display in reaction to new data provided by Model events. View classes should be as passive as possible. One of the most common mistakes in non-maintainable software is a View class that acts as a Controller or that "reaches into" the Model for data rather than accepting values passed in as event arguments. :

UIViewController, Interface Builder, Storyboards, and Nib files

XCode, Apple’s IDE, contains Interface Builder (“IB”), a tool that allows user interfaces to be created interactively and saved as “Nib” files (these are saved in XML format with the “.xib” extension). Xamarin Studio generates Code Behind classes for nib files and generally these will be subclasses of UIViewController. Starting with iOS 5, application developers can use “Storyboards” to visually specify navigation amongst individual UIViewControllers. For more on Storyboards, see Introduction to Storyboards.

Universal applications

Xamarin Studio fully supports universal applications that use a single UIViewController to control multiple UIViews customized for the iPad or the iPhone. As long as the UIViews used by the two devices share the same elements, they can share the same Outlets and Actions, as described in the "iPad + Universal (iPhone + iPad) Apps" guide.

It is not necessary for the iPhone and iPad versions to use the same UI elements, however. The application developer may wish to take advantage of the increased screen real-estate and larger set of controls available on the iPad. In such cases, the application developer should create separate UIViewControllers and load them appropriatel using code similar to the following, again taken from the “iPad + Universal (iPhone + iPad) Apps“ guide. The choice of the UIViewController to be loaded is determined at runtime based on a call to P:UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom.

if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
    homeScreen = new Screens.HomeScreen_iPhone();
} else {
    homeScreen = new Screens.HomeScreen_iPad();
}
window.RootViewController = homeScreen;

State Restoration

If you want to provide state restoration in your class, you need to manually add a method with the following signature to your class:

[Adopts ("UIViewControllerRestoration")]
class MyUIViewController : UIViewController {

 [Export ("viewControllerWithRestorationIdentifierPath:")]
 static UIViewController FromIdentifierPath (string [] identifierComponents, NSCoder coder)
 {
    var sb = (UIStoryboard) coder.DecodeObject (UIStateRestoration.ViewControllerStoryboardKey);
    if (sb != null){
       var vc = (MyUIViewController) sb.InstantiateViewController ("MyViewController");
       vc.RestorationIdentifier = identifierComponents [identifierComponents.Length-1];
       vc.RestorationClass = Class.GetHandle (typeof (MyViewController));
    }
 }
}

UIViewController Subclasses

ClassUse-caseExample Image
UIActivityViewController Choose from a set of possible activities
UIPageViewController Presents content view controllers as a series of pages
UINavigationController Presents content view controllers one at a time, with a header and optional toolbar
UIImagePickerController A standard UINavigationController for selecting and taking photographs.
UIVideoEditorController A standard UINavigationController for reviewing and editing video and audio files.
UITabBarController Top-level controller that presents view controllers one at a time, selected by a toolbar along the bottom of the screen.
UIReferenceLibraryViewController A standard view controller that presents a term and it's dictionary definition.
UISplitViewController An iPad-only view controller that presents side-by-side view controllers.
UICollectionViewController Efficiently displays a large number of cells, arranged in a flexible manner.
UITableViewController Efficiently displays a large number of cells, arranged vertically.

Adaptive Layout and Rotation

Starting with iOS 8 a series of idioms were introduced into iOS 8 to assist developers in creating applications and UIViewControllers that would work with different form factors, like both iPhone and iPad.

This replaces the pre-iOS8 design that focused on supporting two different form factors (iPhone or iPad) in a particular orientation as well as supporting the transitions from one interface orientation to the other.

New applications should take a number of variables into consideration when laying out the elements on their UI. These include the available size in the canvas, UserInterfaceIdiom (iPad or iPhone), the display scale, and both the vertical and horizontal size classes. The first one is the size of your main view, while the rest are stored in the TraitCollection.

Rotation is now considered a class size change. For example an iPhone held in portrait mode has a regular height and a compact width. When you switch it to landscape, it becomes a compact height and a regular width.

Applications can override TraitCollectionDidChange(UITraitCollection) to react to changes to any of the user interface traits. This method will be invoked during rotations or changes to the user interface that affect the size class of the application.

The ViewWillTransitionToSize(CGSize, IUIViewControllerTransitionCoordinator) method is invoked when rotation takes place.

MVC, MVP, and MVVM

.NET developers will be familiar with Microsoft-promoted architectures that serve the same goal as MVC. Both Model-View-Presenter (MVP) and Model-View-ViewModel (MVVM) strive to maintain the separation between Model classes and display classes. Developers familiar with MVP will be used to Model data flowing through a coordinating Presenter object towards the View rather than MVC’s model in which Views directly subscribe to Model events. It is possible to do an MVP architecture in iOS by increasing the responsibilities of a UIViewController. The defining characteristic of MVVM is the use of databinding to ensure that View objects are reactive. iOS controls do not support databinding so MVVM is not possible. MVVM developers will be used to more of a "firewall" between View and Model objects than is available in MVC. MVVM developers should remind themselves to ensure their View objects are as reactive as possible and are not reaching in to the Model for data or taking over Controller responsibilities.

UIViewController and MonoTouch.Dialog

MonoTouch.Dialog (“MT.D”) allows complex UIs to be rapidly built using declarative statements. As opposed to applications built using Apple’s Interface Builder, most MT.D applications use the predefined DialogViewController and do not create their own subclass of UIViewController. For more information, refer to the N:MonoTouch.Dialog namespace documentation and the article Introduction to MonoTouch.Dialog.

Constructors

UIViewController()

Default constructor that initializes a new instance of this class with no parameters.

UIViewController(IntPtr)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

UIViewController(NSCoder)

A constructor that initializes the object from the data stored in the unarchiver object.

UIViewController(NSObjectFlag)

Constructor to call on derived classes to skip initialization and merely allocate the object.

UIViewController(String, NSBundle)

A constructor used when creating a view controller using the information that is stored in the nib file.

Properties

AccessibilityAssistiveTechnologyFocusedIdentifiers (Inherited from UIResponder)
AccessibilityCustomActions

Allows methods to be added to AccessibilityCustomActions as accessibility-supporting supplementary actions.

(Inherited from UIResponder)
AccessibilityDragSourceDescriptors (Inherited from UIResponder)
AccessibilityDropPointDescriptors (Inherited from UIResponder)
AdditionalSafeAreaInsets

Gets or sets additional safe area insets to account for app-specific tool bars and other app-specific UI.

AutomaticallyAdjustsScrollViewInsets

Developers should not use this deprecated property. Developers should use 'UIScrollView.ContentInsetAdjustmentBehavior' instead.

AutomaticallyForwardAppearanceAndRotationMethodsToChildViewControllers

Determines whether the containment events are automatically propagaged to nested view controllers.

BottomLayoutGuide

Developers should not use this deprecated property. Instead, they should use SafeAreaLayoutGuide.

CanBecomeFirstResponder

Determines whether this UIREsponder is willing to become the first responder.

(Inherited from UIResponder)
CanResignFirstResponder

Determines whether this UIResponder is willing to give up its first responder status.

(Inherited from UIResponder)
ChildViewControllerForHomeIndicatorAutoHidden

Gets a child view controller for determining whether to display an indicator for returning to the Home screen.

ChildViewControllerForScreenEdgesDeferringSystemGestures

Gets the child view controller that has precedence when processing screen edge gestures, if present.

ChildViewControllers

An array of UIViewControllers that are managed by this UIViewController.

Class (Inherited from NSObject)
ClassHandle

The handle for this class.

ContentSizeForViewInPopover

Default content size for popovers.

DebugDescription

A developer-meaningful description of this object.

(Inherited from NSObject)
DefinesPresentationContext

Specifies whether this UIViewController’s View is shown when presenting another UIViewController.

Description

Description of the object, the Objective-C version of ToString.

(Inherited from NSObject)
DisablesAutomaticKeyboardDismissal

If true, input view will remain on-screen even when non-input control is tapped.

EdgesForExtendedLayout

Specifies how the ParentViewController should extend the layout of this UIViewController.

EditButtonItem

A UIBarButtonItem that toggles between statees "Edit" and "Done."

Editing

true if the UIViewController allows the application user to edit the UIView contents.

ExtendedLayoutIncludesOpaqueBars

Whether the extended layout includes opaque bars.

ExtensionContext

Gets the NSExtensionContext for this view controller.

FocusItemContainer

Gets the container for the focus envirnoment's children.

Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from NSObject)
HidesBottomBarWhenPushed

Specifies whether the toolbar should be visible when this UIViewController is pushed onto a UINavigationController.

HierarchyInconsistencyException

Constant used to identify broken UIViewController hierarchies.

InputAccessoryView

Custom view that can be attached when the object becomes the first responder.

(Inherited from UIResponder)
InputAccessoryViewController

Gets the custom accessory UIInputViewController to display when this UIResponder becomes the first responder.

(Inherited from UIResponder)
InputAssistantItem

Gets the assistant that will be used to configure the shortcut bar.

(Inherited from UIResponder)
InputView

Custom view to display when the object becomes the first responder. Read-only.

(Inherited from UIResponder)
InputViewController

Gets the custom UIInputViewController to display when this UIResponder becomes the first responder.

(Inherited from UIResponder)
InterfaceOrientation

The current orientation of the interface.

IsBeingDismissed

true if the current UIViewController is in the process of being dismissed.

IsBeingPresented

true if the current UIViewController is in the process of being presented.

IsDirectBinding (Inherited from NSObject)
IsFirstResponder

Returns whether this UIResponder is the First Responder.

(Inherited from UIResponder)
IsMovingFromParentViewController

true if the current UIViewController is in the process of being removed from its parent UIViewController.

IsMovingToParentViewController

true if the current UIViewController is in the process of being added to a parent UIViewController.

IsProxy (Inherited from NSObject)
IsViewLoaded

A Boolean indicating whether the View is loaded into memory.

KeyCommands

The key commands that should trigger action on this UIResponder. Read-only.

(Inherited from UIResponder)
ModalInPopover

true if this UIViewController should be presented modally by a UIPopoverController.

ModalPresentationCapturesStatusBarAppearance

Whether the UIViewController, when presented modally but non-fullscreen, takes over control of the status bar.

ModalPresentationStyle

The UIModalPresentationStyle to be used when presenting UIViewControllers.

ModalTransitionStyle

The UIModalTransitionStyle to be used by PresentViewController(UIViewController, Boolean, Action).

ModalViewController

Controller for the active presented view.

NavigationController

The nearest ancestor UINavigationController

NavigationItem

A UINavigationItem that represents this UIViewController in its parent’s UINavigationController’s NavigationBar.

NextResponder

The next responder on the response chain

(Inherited from UIResponder)
NibBundle

The NSBundle from which this UIViewController was instantiated.

NibName

The name of the nib file from which this UIViewController was instantiated, or null.

ParentFocusEnvironment

Gets the focus environment that contains the current focus environment.

ParentViewController

The UIViewController that contains this UIViewController.

PasteConfiguration

The UIPasteConfiguration supported by this object.

(Inherited from UIResponder)
PopoverPresentationController

Gets the nearest ancestor in the view hierarchy that is a UIPopoverPresentationController or null if there is none.

PreferredContentSize

Gets the preferred size for the content of the container.

PreferredFocusedView

If not null, indicates the child UIView that should receive focus by default.

PreferredFocusEnvironments

An array of IUIFocusEnvironments that are recursively searched by the system to find the default focused view.

PreferredScreenEdgesDeferringSystemGestures

Gets the screen edges whose gestures take precedence over system gestures.

PreferredStatusBarUpdateAnimation

The preferred animation style for hiding and showing the status bar.

PrefersHomeIndicatorAutoHidden

Gets a Boolean value that tells if it is preferred that the Home indicator be hidden.

PresentationController

Gets the nearest ancestor in the view hierarchy that is a UIPresentationController or null if there is none.

PresentedViewController

The UIViewController that is being presented by this UIViewController or one of this’s ancestor UIViewControllers.

PresentingViewController

The UIViewController that is presenting this UIViewController.

PreviewActionItems

Gets the array of IUIPreviewActionItem that are displayed when the user swipes upwards in 3D Touch Preview.

ProvidesPresentationContextTransitionStyle

true if this UIViewController overrides the transition style of the UIViewController that it presents.

RestorationClass

The class responsible for restoring application state.

RestorationIdentifier

Specifies the instance of the UIViewController for restoration.

RestoresFocusAfterTransition

Gets or sets whether this UIViewController restores focus after being transitioned to.

RetainCount

Returns the current Objective-C retain count for the object.

(Inherited from NSObject)
RotatingFooterView

The footer view that needs to be transitioned during an interface rotation

RotatingHeaderView

The header view that needs to be transitioned during an interface rotation.

SearchDisplayController

The UISearchDisplayController, if any, associated with this UIViewController.

Self (Inherited from NSObject)
ShouldAutomaticallyForwardAppearanceMethods

Whether appearance methods should be forwarded to child UIViewControllers.

ShouldAutomaticallyForwardRotationMethods

Whether rotation methods should be forwarded to child UIViewControllers.

ShowDetailTargetDidChangeNotification

Notification constant for ShowDetailTargetDidChange

SplitViewController

The nearest ancestor UISplitViewController or null.

Storyboard

The UIStoryboard from which this UIViewController was created, or null.

Superclass (Inherited from NSObject)
SuperHandle

Handle used to represent the methods in the base class for this NSObject.

(Inherited from NSObject)
SystemMinimumLayoutMargins

Gets the root view's minimum layout margins.

TabBarController

The nearest ancestore UITabBarController or null.

TabBarItem

A UITabBarItem that represents this UIViewController in its parent’s UITabBarController’s TabBar.

TextInputContextIdentifier

An identifier indicating that this UIResponder should preserve its text input mode information. Read-only.

(Inherited from UIResponder)
TextInputMode

The text input mode for this UIResponder. Read-only.

(Inherited from UIResponder)
Title

A human-meaningful identifier of this UIViewController.

ToolbarItems

The array of UIBarButtonItems on a UINavigationController’s Toolbar

TopLayoutGuide

Developers should not use this deprecated property. Instead, they should use SafeAreaLayoutGuide.

TraitCollection

Characteristics of the display, such as it's idiom, scale, and size class.

TransitioningDelegate

A delegate object that is responsible for producing IUIViewControllerAnimatedTransitionings for custom presentation.

UndoManager

The nearest shared NSUndoManager in the responder chain. Read-only.

(Inherited from UIResponder)
UserActivity

Action that encapsulates a user activity that is supported by this responder.

(Inherited from UIResponder)
View

The view managed by this view controller.

ViewIfLoaded

Returns the View if it has been instantiated; otherwise, returns null.

ViewRespectsSystemMinimumLayoutMargins

Gets or sets a Boolean value that controls whether the view for the view controller respects the minimum layout margins.

WantsFullScreenLayout

true if the view should overlap the status bar.

WeakTransitioningDelegate

The delegate object used to provide controllers for transition animations and interactions.

Zone (Inherited from NSObject)

Methods

AccessibilityDecrement()

Tells the accessibility element to decrement the value of its content.

(Inherited from UIResponder)
AccessibilityElementDidBecomeFocused()

Indicates that an assistive technology has set its focus to this UIResponder.

(Inherited from UIResponder)
AccessibilityElementDidLoseFocus()

Indicates that an assistive technology has changed its focus from this UIResponder.

(Inherited from UIResponder)
AccessibilityElementIsFocused()

Indicates whether an assistive technology is focused on this UIResponder.

(Inherited from UIResponder)
AccessibilityIncrement()

Tells the accessibility element to increment the value of its content.

(Inherited from UIResponder)
AccessibilityPerformEscape()

Tells the accessibility system to dismiss a modal popover or hierarchically-displayed element.

(Inherited from UIResponder)
AccessibilityPerformMagicTap()

Toggles the application-defined "most important state" of the app.

(Inherited from UIResponder)
AccessibilityScroll(UIAccessibilityScrollDirection)

When overridden, allows the accessibility system to perform scrolling.

(Inherited from UIResponder)
Add(UIView)

This is an alias for AddSubview(UIView), but uses the Add pattern as it allows C# 3.0 constructs to add subviews after creating the object.

AddChildViewController(UIViewController)

Adds a UIViewController as a child.

AddKeyCommand(UIKeyCommand)

Adds command as a shortcut available to attached hardware keyboards.

AddObserver(NSObject, NSString, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using NSString keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using string keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSString, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
AddObserver(String, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
ApplicationFinishedRestoringState()

Called when object decoding is complete during state restoration.

AttemptRotationToDeviceOrientation()

Programmatically triggers rotation of views.

AwakeFromNib()

Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().

(Inherited from NSObject)
BecomeFirstResponder()

Request the object to become the first responder.

(Inherited from UIResponder)
BeginAppearanceTransition(Boolean, Boolean)

With EndAppearanceTransition(), tells child UIViewControllers that their UIViews are about to either appear or disappear.

BeginInvokeOnMainThread(Action) (Inherited from NSObject)
BeginInvokeOnMainThread(Selector, NSObject)

Invokes asynchrously the specified code on the main UI thread.

(Inherited from NSObject)
BeginRequestWithExtensionContext(NSExtensionContext)

Method that is called when the host app is about to make a request.

Bind(NSString, NSObject, String, NSDictionary) (Inherited from NSObject)
Bind(String, NSObject, String, NSDictionary)
Obsolete.
(Inherited from NSObject)
BindingInfo(String)
Obsolete.
(Inherited from NSObject)
BindingOptionDescriptions(String)
Obsolete.
(Inherited from NSObject)
BindingValueClass(String)
Obsolete.
(Inherited from NSObject)
CanPaste(NSItemProvider[])

Gets whether this can accept a paste operation by the .

(Inherited from UIResponder)
CanPerform(Selector, NSObject)

Determines if this UIResponder can perform the specified action. Typically used to probe for editing commands.

(Inherited from UIResponder)
CanPerformUnwind(Selector, UIViewController, NSObject)

Specifies whether this UIViewController supports the specific unwind segue

ChildViewControllerForStatusBarHidden()

When overridden, returns the UIViewController that determines whether the status bar is hidden or unhidden.

ChildViewControllerForStatusBarStyle()

When overridden, returns the UIViewController that determines the style of the status bar.

CommitEditing() (Inherited from NSObject)
CommitEditing(NSObject, Selector, IntPtr) (Inherited from NSObject)
ConformsToProtocol(IntPtr)

Invoked to determine if this object implements the specified protocol.

(Inherited from NSObject)
Copy()

Performs a copy of the underlying Objective-C object.

(Inherited from NSObject)
Copy(NSObject)

Indicates a "Copy" editing operation.

(Inherited from UIResponder)
Cut(NSObject)

Indicates a "Cut" editing operation.

(Inherited from UIResponder)
DangerousAutorelease() (Inherited from NSObject)
DangerousRelease() (Inherited from NSObject)
DangerousRetain() (Inherited from NSObject)
DecodeRestorableState(NSCoder)

With EncodeRestorableState(NSCoder), allows custom state restoration.

Delete(NSObject)

Indicates a "Delete" editing operation.

(Inherited from UIResponder)
DidAnimateFirstHalfOfRotation(UIInterfaceOrientation)

Deprecated function called at end of first-part of two-step rotation animations.

DidChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates a change occurred to the indexes for a to-many relationship.

(Inherited from NSObject)
DidChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
DidChangeValue(String)

Indicates that a change occurred on the specified key.

(Inherited from NSObject)
DidMoveToParentViewController(UIViewController)

Called after this is added or removed from a parent UIViewController.

DidReceiveMemoryWarning()

Called when the system is running low on memory.

DidRotate(UIInterfaceOrientation)

Called after the UI has rotated.

DidUpdateFocus(UIFocusUpdateContext, UIFocusAnimationCoordinator)

Indicates that the focus changed as detailed in the context.

DismissModalViewController(Boolean)

Dismisses the modal view controller that was submitted by the receiver.

DismissMoviePlayerViewController()

Dismisses the MPMoviePlayerViewController.

DismissViewController(Boolean, Action)

Dismisses the presented view controller.

DismissViewControllerAsync(Boolean)

Dismisses the presented view controller.

Dispose()

Releases the resources used by the NSObject object.

(Inherited from NSObject)
Dispose(Boolean)

Releases the resources used by the UIViewController object.

DoesNotRecognizeSelector(Selector)

Indicates that this object does not recognize the specified selector.

(Inherited from NSObject)
EncodeRestorableState(NSCoder)

With DecodeRestorableState(NSCoder), allows custom state restoration.

EncodeTo(NSCoder)

Encodes the state of the object on the provided encoder

EndAppearanceTransition()

With BeginAppearanceTransition(Boolean, Boolean), tells child UIViewControllers that their child views have just appeared or disappeared.

Equals(NSObject) (Inherited from NSObject)
Equals(Object) (Inherited from NSObject)
ExposedBindings() (Inherited from NSObject)
GetAllowedChildViewControllersForUnwinding(UIStoryboardUnwindSegueSource)

The array of child UIViewController objects that should be searched to determine if they are the unwind segue destination.

GetBindingInfo(NSString) (Inherited from NSObject)
GetBindingOptionDescriptions(NSString) (Inherited from NSObject)
GetBindingValueClass(NSString) (Inherited from NSObject)
GetChildViewControllerContainingSegueSource(UIStoryboardUnwindSegueSource)

The child UIViewController that is the source of the unwind segue.

GetDictionaryOfValuesFromKeys(NSString[])

Retrieves the values of the specified keys.

(Inherited from NSObject)
GetEnumerator()

Returns an enumerator that lists all of the child UIViews

GetHashCode()

Generates a hash code for the current instance.

(Inherited from NSObject)
GetMethodForSelector(Selector) (Inherited from NSObject)
GetNativeField(String)
Obsolete.
(Inherited from NSObject)
GetNativeHash() (Inherited from NSObject)
GetOverrideTraitCollectionForChildViewController(UIViewController)

Gets the UITraitCollection for the specified child view controller of this controller.

GetSegueForUnwinding(UIViewController, UIViewController, String)

Defines the segue to be used between two UIViewControllers.

GetSizeForChildContentContainer(IUIContentContainer, CGSize)

Gets the size of the content of the specified child IUIContentContainer by using the size of the parent container.

GetSupportedInterfaceOrientations()

The orientations supported by this UIViewController.

GetTargetForAction(Selector, NSObject)

Returns the object that responds to an action.

(Inherited from UIResponder)
GetTargetViewControllerForAction(Selector, NSObject)

Gets the view controller for the specified action and sender.

GetViewControllerForUnwind(Selector, UIViewController, NSObject)

Used for searching child UIViewControllers for a specific unwind segue.

Init() (Inherited from NSObject)
InitializeHandle(IntPtr, String) (Inherited from NSObject)
InitializeHandle(IntPtr) (Inherited from NSObject)
Invoke(Action, Double) (Inherited from NSObject)
Invoke(Action, TimeSpan) (Inherited from NSObject)
InvokeOnMainThread(Action) (Inherited from NSObject)
InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

(Inherited from NSObject)
IsEqual(NSObject) (Inherited from NSObject)
IsKindOfClass(Class) (Inherited from NSObject)
IsMemberOfClass(Class) (Inherited from NSObject)
LoadView()

Initializes the View property.

LoadViewIfNeeded()

If necessary, synchronously loads the View from a Storyboard or NIB.

MakeTextWritingDirectionLeftToRight(NSObject)

Sets the direction in which text is written to be left-to-right.

(Inherited from UIResponder)
MakeTextWritingDirectionRightToLeft(NSObject)

Sets the direction in which text is written to be right-to-left.

(Inherited from UIResponder)
MarkDirty()

Promotes a regular peer object (IsDirectBinding is true) into a toggleref object.

(Inherited from NSObject)
MotionBegan(UIEventSubtype, UIEvent)

Method invoked when a motion (a shake) has started.

(Inherited from UIResponder)
MotionCancelled(UIEventSubtype, UIEvent)

Method invoked if the operating system cancels a motion (shake) event.

(Inherited from UIResponder)
MotionEnded(UIEventSubtype, UIEvent)

Method invoked when a motion (shake) has finished.

(Inherited from UIResponder)
MutableCopy()

Creates a mutable copy of the specified NSObject.

(Inherited from NSObject)
ObjectDidEndEditing(NSObject) (Inherited from NSObject)
ObserveValue(NSString, NSObject, NSDictionary, IntPtr)

Indicates that the value at the specified keyPath relative to this object has changed.

(Inherited from NSObject)
Paste(NSItemProvider[])

Called to perform a paste operation from .

(Inherited from UIResponder)
Paste(NSObject)

Indicates a "Paste" editing operation.

(Inherited from UIResponder)
PerformSegue(String, NSObject)

Performs the specified UIStoryboardSegue.

PerformSelector(Selector, NSObject, Double, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSObject, Double)

Invokes the selector on the current instance and if the obj is not null, it passes this as its single parameter.

(Inherited from NSObject)
PerformSelector(Selector, NSObject, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean) (Inherited from NSObject)
PerformSelector(Selector) (Inherited from NSObject)
PreferredContentSizeDidChangeForChildContentContainer(IUIContentContainer)

Notifies this controller that the preferred size for content for a specified child container has changed.

PreferredInterfaceOrientationForPresentation()

The orientation that best displays the content of this UIViewController.

PreferredStatusBarStyle()

The preferred UIStatusBarStyle for this UIViewController.

PrefersStatusBarHidden()

Whether this UIViewController prefers the status bar to be hidden.

PrepareForInterfaceBuilder() (Inherited from NSObject)
PrepareForInterstitialAds()

Prepares the view controller to display interstitial ads.

PrepareForSegue(UIStoryboardSegue, NSObject)

Informs the application that a UIStoryboardSegue is about to be executed.

PresentModalViewController(UIViewController, Boolean)

Application developers should use PresentViewController(UIViewController, Boolean, Action) instead of this deprecated method.

PresentMoviePlayerViewController(MPMoviePlayerViewController)

Displays a movie controller using the standard transition.

PresentViewController(UIViewController, Boolean, Action)

Modally presents a view controller.

PresentViewControllerAsync(UIViewController, Boolean)

Modally presents a view controller.

PressesBegan(NSSet<UIPress>, UIPressesEvent)

Indicates that a physical button has been pressed on a remote or game controller.

(Inherited from UIResponder)
PressesCancelled(NSSet<UIPress>, UIPressesEvent)

Indicates a physical button-press event has been cancelled due to a system event.

(Inherited from UIResponder)
PressesChanged(NSSet<UIPress>, UIPressesEvent)

Indicates that the Force value of the evt has changed.

(Inherited from UIResponder)
PressesEnded(NSSet<UIPress>, UIPressesEvent)

Indicates the ending of a press of a physical button on a remote or game controller.

(Inherited from UIResponder)
RegisterForPreviewingWithDelegate(IUIViewControllerPreviewingDelegate, UIView)

Registers this view controller for 3D Touch peek and pop operations.

ReloadInputViews()

Updates custom input and accessory views when this object is the first responder.

(Inherited from UIResponder)
RemoteControlReceived(UIEvent)

Indicates that a remote-control event was received.

(Inherited from UIResponder)
RemoveFromParentViewController()

Removes this UIViewController from its ParentViewControllerUIViewController.

RemoveKeyCommand(UIKeyCommand)

Removes a previously-added hardware-keyboard accelerator.

RemoveObserver(NSObject, NSString, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, NSString)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RemoveObserver(NSObject, String, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, String)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
ResignFirstResponder()

Called when this UIResponder has been asked to resign its first responder status.

(Inherited from UIResponder)
RespondsToSelector(Selector)

Whether this object recognizes the specified selector.

(Inherited from NSObject)
RestoreUserActivityState(NSUserActivity)

Restores the state that is necessary for continuance of the specified user activity.

(Inherited from UIResponder)
Select(NSObject)

Indicates a "Select" editing operation.|b

(Inherited from UIResponder)
SelectAll(NSObject)

Indicates a "Select All" editing operation.

(Inherited from UIResponder)
SetEditing(Boolean, Boolean)

Turns editing mode on or off.

SetNativeField(String, NSObject)
Obsolete.
(Inherited from NSObject)
SetNeedsFocusUpdate()

When this is the active focus environment, requests a focus update, which can potentially change the PreferredFocusedView. (See also UpdateFocusIfNeeded().)

SetNeedsStatusBarAppearanceUpdate()

Notifies the system that the attributes of the status bar have been changed.

SetNeedsUpdateOfHomeIndicatorAutoHidden()

Controls whether the developer's view controller should display the indicator for returning to the Home screen..

SetNeedsUpdateOfScreenEdgesDeferringSystemGestures()

Changes the screen edges whose gestures take precedence over system gestures.

SetNilValueForKey(NSString)

Sets the value of the specified key to null.

(Inherited from NSObject)
SetOverrideTraitCollection(UITraitCollection, UIViewController)

Sets the UITraitCollection object for the specified child view controller of this controller.

SetToolbarItems(UIBarButtonItem[], Boolean)

Adds UIBarButtonItems to the UIToolbar

SetValueForKey(NSObject, NSString)

Sets the value of the property specified by the key to the specified value.

(Inherited from NSObject)
SetValueForKeyPath(IntPtr, NSString)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

(Inherited from NSObject)
SetValueForKeyPath(NSObject, NSString)

Sets the value of a property that can be reached using a keypath.

(Inherited from NSObject)
SetValueForUndefinedKey(NSObject, NSString)

Indicates an attempt to write a value to an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
SetValuesForKeysWithDictionary(NSDictionary)

Sets the values of this NSObject to those in the specified dictionary.

(Inherited from NSObject)
ShouldAutorotate()

Turns auto-rotation on or off.

ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)

true if the UIViewController supports rotation to the specified UIInterfaceOrientation.

ShouldPerformSegue(String, NSObject)

Whether the segue should be performed.

ShouldUpdateFocus(UIFocusUpdateContext)

Called prior to the this either losing or receiving focus. If either focus environment returns false, the focus update is canceled.

ShowDetailViewController(UIViewController, NSObject)

Shows this view controller in a detail context.

ShowViewController(UIViewController, NSObject)

Shows this view controller.

SystemLayoutFittingSizeDidChangeForChildContentContainer(IUIContentContainer)

Notifies this container that auto layout resized a specified child container.

ToggleBoldface(NSObject)

Toggles the use of a bold font.

(Inherited from UIResponder)
ToggleItalics(NSObject)

Toggles the use of an italic font.

(Inherited from UIResponder)
ToggleUnderline(NSObject)

Toggles the use of underlining.

(Inherited from UIResponder)
ToString()

Returns a string representation of the value of the current instance.

(Inherited from NSObject)
TouchesBegan(NSSet, UIEvent)

Sent when one or more fingers touches the screen.

(Inherited from UIResponder)
TouchesCancelled(NSSet, UIEvent)

Sent when the touch processing has been cancelled.

(Inherited from UIResponder)
TouchesEnded(NSSet, UIEvent)

Sent when one or more fingers are lifted from the screen.

(Inherited from UIResponder)
TouchesEstimatedPropertiesUpdated(NSSet)

Called when the estimated properties of touches have been updated.

(Inherited from UIResponder)
TouchesMoved(NSSet, UIEvent)

Sent when one or more fingers move on the screen.

(Inherited from UIResponder)
TraitCollectionDidChange(UITraitCollection)

Method invoked when the trait collection for the view controller changed.

Transition(UIViewController, UIViewController, Double, UIViewAnimationOptions, Action, UICompletionHandler)

Used for transitioning between two view controller'€™s child view controllers.

TransitionAsync(UIViewController, UIViewController, Double, UIViewAnimationOptions, Action)

Used for transitioning between two view controller'€™s child view controllers.

Unbind(NSString) (Inherited from NSObject)
Unbind(String)
Obsolete.
(Inherited from NSObject)
UnregisterForPreviewingWithContext(IUIViewControllerPreviewing)

Stops previewing from handling 3D Touch peek and pop input.

Unwind(UIStoryboardSegue, UIViewController)

Called during an unwind segue on any UIViewController objects in the unwind path.

UpdateFocusIfNeeded()

If any focus environment has a pending update, this method forces an immediate focus update. Unlike SetNeedsFocusUpdate(), this method may be called by any UIViewController, whether it currently contains focus or not.

UpdateUserActivityState(NSUserActivity)

Updates a given user activity state.

(Inherited from UIResponder)
UpdateViewConstraints()

Called when the UIViewController needs to recalculate its layout constraints.

ValueForKey(NSString)

Returns the value of the property associated with the specified key.

(Inherited from NSObject)
ValueForKeyPath(NSString)

Returns the value of a property that can be reached using a keypath.

(Inherited from NSObject)
ValueForUndefinedKey(NSString)

Indicates an attempt to read a value of an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
ViewDidAppear(Boolean)

Called after the View is added to the view hierarchy.

ViewDidDisappear(Boolean)

This method is called after the UIViewthat is this UIViewController’s View property is removed from the display UIView hierarchy.

ViewDidLayoutSubviews()

Called after the View has laid out its subviews.

ViewDidLoad()

Called after the controller’s View is loaded into memory.

ViewDidUnload()

In iOS 6 and later, this method is never called. In prior versions it was called when the controller’s view was released from memory.

ViewLayoutMarginsDidChange()

Method that is called when the layout margins for the view are changed.

ViewSafeAreaInsetsDidChange()

Method that is called when the safe area insets are changed by size changes to system bars or by changes to the AdditionalSafeAreaInsets property.

ViewWillAppear(Boolean)

Called prior to the View being added to the view hierarchy.

ViewWillDisappear(Boolean)

This method is called prior to the removal of the UIViewthat is this UIViewController’s View from the display UIView hierarchy.

ViewWillLayoutSubviews()

Called before the View lays out its subviews.

ViewWillTransitionToSize(CGSize, IUIViewControllerTransitionCoordinator)

For UIViewController objects that are part of an app extension, called prior to the View being resized.

ViewWillUnload()

In iOS 6 and later, this method is never called. In prior versions it was called prior to the controller’s view was released from memory.

WillAnimateFirstHalfOfRotation(UIInterfaceOrientation, Double)

Deprecated method sent during the first half of a rotation. Application developers should instead use WillAnimateRotation(UIInterfaceOrientation, Double).

WillAnimateRotation(UIInterfaceOrientation, Double)

Called prior to a one-step interface rotation.

WillAnimateSecondHalfOfRotation(UIInterfaceOrientation, Double)

Deprecated method sent during the second half of a rotation. Application developers should instead use WillAnimateRotation(UIInterfaceOrientation, Double).

WillChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates that the values of the specified indices in the specified key are about to change.

(Inherited from NSObject)
WillChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
WillChangeValue(String)

Indicates that the value of the specified key is about to change.

(Inherited from NSObject)
WillMoveToParentViewController(UIViewController)

Called prior to adding or removing this from a container UIViewController.

WillRotate(UIInterfaceOrientation, Double)

Called prior to a user interface rotation.

WillTransitionToTraitCollection(UITraitCollection, IUIViewControllerTransitionCoordinator)

Notifies this that its trait collection will change to traitCollection, as coordinated by coordinator.

Extension Methods

GetDebugDescription(INSObjectProtocol)
DisplayingBannerAd(UIViewController)
GetCanDisplayBannerAds(UIViewController)
GetInterstitialPresentationPolicy(UIViewController)
GetOriginalContentView(UIViewController)
PresentingFullScreenAd(UIViewController)
RequestInterstitialAdPresentation(UIViewController)
SetCanDisplayBannerAds(UIViewController, Boolean)
SetInterstitialPresentationPolicy(UIViewController, ADInterstitialPresentationPolicy)
ShouldPresentInterstitialAd(UIViewController)
GetAccessibilityCustomRotors(NSObject)

Gets the array of UIAccessibilityCustomRotor objects appropriate for this object.

SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor[])

Sets the array of UIAccessibilityCustomRotor objects appropriate for this object.

GetTransitionCoordinator(UIViewController)

The IUIViewControllerTransitionCoordinator coordinating the transition of the specified UIViewController.

GetFocusItemContainer(IUIFocusEnvironment)

Gets the focus container for the environment.

GetParentFocusEnvironment(IUIFocusEnvironment)

Gets the parent focus environment.

GetPreferredFocusEnvironments(IUIFocusEnvironment)

Gets the list of focus environments, ordered by priority, that the environment prefers when updating the focus.

CanPaste(IUIPasteConfigurationSupporting, NSItemProvider[])

Returns true if the responder can paste from the specified item providers.

Paste(IUIPasteConfigurationSupporting, NSItemProvider[])

Performs the paste.

DecreaseSize(UIResponder, NSObject)

A hardware keyboard request (Command-minus) to decrease the size of the UIResponder.

IncreaseSize(UIResponder, NSObject)

A hardware keyboard request (Command-plus) to increase the size of the UIResponder.

CollapseSecondaryViewController(UIViewController, UIViewController, UISplitViewController)

Collapses the secondary view controller on splitViewController

GetSplitViewController(UIViewController)

Returns te split view controller for the nested view controller.

SeparateSecondaryViewControllerForSplitViewController(UIViewController, UISplitViewController)

Returns the separate secondary view controller for splitViewController.

Applies to

See also