The view that the controller manages.
SDKs
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
var view: UIView! { get set }
Discussion
The view stored in this property represents the root view for the view controller's view hierarchy. The default value of this property is nil
.
If you access this property and its value is currently nil
, the view controller automatically calls the load
method and returns the resulting view.
Each view controller object is the sole owner of its view. You must not associate the same view object with multiple view controller objects. The only exception to this rule is that a container view controller implementation may add this view as a subview in its own view hierarchy. Before adding the subview, the container must first call its add
method to create a parent-child relationship between the two view controller objects.
Because accessing this property can cause the view to be loaded automatically, you can use the is
method to determine if the view is currently in memory. Unlike this property, the is
property does not force the loading of the view if it is not currently in memory.
The UIView
class can automatically set this property to nil
during low-memory conditions and also when the view controller itself is finally released.
For more information about how a view controller loads and unloads its view, see View Controller Programming Guide for iOS.