Class: UIViewController
- Inherits:
-
UIResponder
- Object
- NSObject
- UIResponder
- UIViewController
Overview
The UIViewController class provides the fundamental view-management model for all iOS apps. You rarely instantiate UIViewController objects directly. Instead, you instantiate subclasses of the UIViewController class based on the specific task each subclass performs. A view controller manages a set of views that make up a portion of your app’s user interface. As part of the controller layer of your app, a view controller coordinates its efforts with model objects and other controller objects—including other view controllers—so your app presents a single coherent user interface.
Direct Known Subclasses
EKCalendarChooser, EKEventViewController, MPMediaPickerController, MPMoviePlayerViewController, PKAddPassesViewController, QLPreviewController, SKStoreProductViewController, SLComposeViewController, UIActivityViewController, UICollectionViewController, UINavigationController, UIPageViewController, UIReferenceLibraryViewController, UISplitViewController, UITabBarController, UITableViewController
Instance Attribute Summary (collapse)
-
- childViewControllers
readonly
An array of the view controllers that are the children of the receiver in the view controller hierarchy.
-
- contentSizeForViewInPopover
The size of the view controller’s view while displayed in a popover.
-
- definesPresentationContext
A Boolean value that indicates whether this view controller’s view is covered when the view controller or one of its descendants presents a view controller.
-
- editing
A Boolean value indicating whether the view controller currently allows the user to edit the view contents.
-
- hidesBottomBarWhenPushed
A Boolean value indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed on to a navigation controller.
-
- interfaceOrientation
readonly
The current orientation of the interface.
-
- modalInPopover
A Boolean value indicating whether the view controller should be presented modally by a popover.
-
- modalPresentationStyle
The presentation style for modally presented view controllers.
-
- modalTransitionStyle
The transition style to use when presenting the receiver.
-
- navigationController
readonly
The nearest ancestor in the view controller hierarchy that is a navigation controller.
-
- navigationItem
readonly
The navigation item used to represent the view controller in a parent’s navigation bar.
-
- nibBundle
readonly
Return the name of the receiver’s nib bundle if it exists.
-
- nibName
readonly
Return the name of the receiver’s nib file, if one was specified.
-
- parentViewController
readonly
The parent view controller of the recipient.
-
- presentedViewController
readonly
The view controller that is presented by this view controller, or one of its ancestors in the view controller hierarchy.
-
- presentingViewController
readonly
The view controller that presented this view controller.
-
- providesPresentationContextTransitionStyle
A Boolean value that indicates whether the view controller defines the transition style for view controllers it presents.
-
- restorationClass
The class responsible for recreating this view controller when restoring the app’s state.
-
- restorationIdentifier
The identifier that determines whether the view controller supports state restoration.
-
- searchDisplayController
readonly
The search display controller associated with the view controller.
-
- splitViewController
readonly
The nearest ancestor in the view controller hierarchy that is a split view controller.
-
- storyboard
readonly
The storyboard from which the view controller originated.
-
- tabBarController
readonly
The nearest ancestor in the view controller hierarchy that is a tab bar controller.
-
- tabBarItem
The tab bar item that represents the view controller when added to a tab bar controller.
-
- title
A localized string that represents the view this controller manages.
-
- toolbarItems
The toolbar items associated with the view controller.
-
- view
The view that the controller manages.
-
- wantsFullScreenLayout
A Boolean value indicating whether the view should underlap the status bar.
Attributes inherited from UIResponder
#inputAccessoryView, #inputView, #undoManager
Class Method Summary (collapse)
-
+ attemptRotationToDeviceOrientation
Attempts to rotate all windows to the orientation of the device.
Instance Method Summary (collapse)
-
- addChildViewController:
Adds the given view controller as a child.
-
- beginAppearanceTransition:animated:
Tells a child controller its appearance is about to change.
-
- canPerformUnwindSegueAction:fromViewController:withSender:
Called on a view controller to determine whether it wants to respond to an unwind action.
-
- decodeRestorableStateWithCoder:
Decodes and restores state-related information for the view controller.
-
- didMoveToParentViewController:
Called after the view controller is added or removed from a container view controller.
-
- didReceiveMemoryWarning
Sent to the view controller when the app receives a memory warning.
-
- didRotateFromInterfaceOrientation:
Sent to the view controller after the user interface rotates.
-
- disablesAutomaticKeyboardDismissal
Returns a Boolean indicating whether the current input view is dismissed automatically when changing controls.
-
- dismissViewControllerAnimated:completion:
Dismisses the view controller that was presented by the receiver.
-
- editButtonItem
Returns a bar button item that toggles its title and associated state between Edit and Done.
-
- encodeRestorableStateWithCoder:
Encodes state-related information for the view controller.
-
- endAppearanceTransition
Tells a child controller its appearance has changed.
-
- initWithNibName:bundle:
Returns a newly initialized view controller with the nib file in the specified bundle.
-
- isBeingDismissed
Returns a Boolean value that indicates whether the view controller is in the process of being dismissed by one of its ancestors.
-
- isBeingPresented
Returns a Boolean value that indicates view controller is in the process of being presented by one of its ancestors.
-
- isMovingFromParentViewController
Returns a Boolean value that indicates that the view controller is in the process of being removed from its parent.
-
- isMovingToParentViewController
Returns a Boolean value that indicates that the view controller is in the process of being added to a parent.
-
- isViewLoaded
Returns a Boolean value indicating whether the view is currently loaded into memory.
-
- loadView
Creates the view that the controller manages.
-
- performSegueWithIdentifier:sender:
Initiates the segue with the specified identifier from the view controller’s storyboard file.
-
- preferredInterfaceOrientationForPresentation
Returns the interface orientation to use when presenting the view controller.
-
- prepareForSegue:sender:
Notifies the view controller that a segue is about to be performed.
-
- presentViewController:animated:completion:
Presents a view controller.
-
- removeFromParentViewController
Removes the receiver from its parent in the view controller hierarchy.
-
- rotatingFooterView
Returns the footer view to transition during an interface orientation change.
-
- rotatingHeaderView
Returns the header view to transition during an interface orientation change.
-
- segueForUnwindingToViewController:fromViewController:identifier:
Called when an unwind segue action needs to transition between two view controllers.
-
- setEditing:animated:
Sets whether the view controller shows an editable view.
-
- setToolbarItems:animated:
Sets the toolbar items to be displayed along with the view controller.
-
- shouldAutomaticallyForwardAppearanceMethods
Returns a Boolean value indicating whether appearance methods are forwarded to child view controllers.
-
- shouldAutomaticallyForwardRotationMethods
Returns a Boolean value indicating whether rotation methods are forwarded to child view controllers.
-
- shouldAutorotate
Returns whether the view controller’s contents should auto rotate.
-
- shouldPerformSegueWithIdentifier:sender:
Determines whether the seque with the specified identifier should be triggered.
-
- supportedInterfaceOrientations
Returns all of the interface orientations that the view controller supports.
-
- transitionFromViewController:toViewController:duration:options:animations:completion:
Transitions between two of the view controller’s child view controllers.
-
- updateViewConstraints
Called when the view controller’s view needs to update its constraints.
-
- viewControllerForUnwindSegueAction:fromViewController:withSender:
Called when an unwind segue action wants to search a container’s children for a view controller to handle the unwind action.
-
- viewDidAppear:
Notifies the view controller that its view was added to a view hierarchy.
-
- viewDidDisappear:
Notifies the view controller that its view was removed from a view hierarchy.
-
- viewDidLayoutSubviews
Notifies the view controller that its view just laid out its subviews.
-
- viewDidLoad
Called after the controller’s view is loaded into memory.
-
- viewWillAppear:
Notifies the view controller that its view is about to be added to a view hierarchy.
-
- viewWillDisappear:
Notifies the view controller that its view is about to be removed from a view hierarchy.
-
- viewWillLayoutSubviews
Notifies the view controller that its view is about to layout its subviews.
-
- willAnimateRotationToInterfaceOrientation:duration:
Sent to the view controller before performing a one-step user interface rotation.
-
- willMoveToParentViewController:
Called just before the view controller is added or removed from a container view controller.
-
- willRotateToInterfaceOrientation:duration:
Sent to the view controller just before the user interface begins rotating.
Methods inherited from UIResponder
#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Array) childViewControllers (readonly)
An array of the view controllers that are the children of the receiver in the view controller hierarchy. (read-only) This property does not include any presented view controllers.This property is only intended to be read by an implementation of a custom container view controller.
- (CGSize) contentSizeForViewInPopover
The size of the view controller’s view while displayed in a popover. This property contains the desired size for the view controller when it is displayed in a popover. By default, the width is set to 320 points and the height is set to 1100 points. You can change these values as needed. The recommended width for popovers is 320 points. If needed, you can return a width value as large as 600 points, but doing so is not recommended.If the popover controller displaying the view controller sets its popoverContentSize property, the popover controller overrides the values set in the view controller’s contentSizeForViewInPopover property.
- (Boolean) definesPresentationContext
A Boolean value that indicates whether this view controller’s view is covered when the view controller or one of its descendants presents a view controller. When a view controller is presented, iOS starts with the presenting view controller and asks it if it wants to provide the presentation context. If the presenting view controller does not provide a context, then iOS asks the presenting view controller’s parent view controller. iOS searches up through the view controller hierarchy until a view controller provides a presentation context. If no view controller offers to provide a context, the window’s root view controller provides the presentation context.If a view controller returns YES, then it provides a presentation context. The portion of the window covered by the view controller’s view determines the size of the presented view controller’s view. The default value for this property is NO.
- (Boolean) editing
A Boolean value indicating whether the view controller currently allows the user to edit the view contents. If YES, the view controller currently allows editing; otherwise, NO. If the view is editable and the associated navigation controller contains an edit-done button, then a Done button is displayed; otherwise, an Edit button is displayed. Clicking either button toggles the state of this property. Add an edit-done button by setting the custom left or right view of the navigation item to the value returned by the editButtonItem method. Set the editing property to the initial state of your view. Use the setEditing:animated: method as an action method to animate the transition of this state if the view is already displayed.
- (Boolean) hidesBottomBarWhenPushed
A Boolean value indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed on to a navigation controller. A view controller added as a child of a navigation controller can display an optional toolbar at the bottom of the screen. The value of this property on the topmost view controller determines whether the toolbar is visible. If the value of this property is YES, the toolbar is hidden. If the value of this property is NO, the bar is visible.
- (UIInterfaceOrientation) interfaceOrientation (readonly)
The current orientation of the interface. (read-only) The possible values are described in UIInterfaceOrientation.
- (Boolean) modalInPopover
A Boolean value indicating whether the view controller should be presented modally by a popover. The default value of this property is NO. Setting it to YES causes an owning popover controller to disallow interactions outside this view controller while it is displayed. You can use this behavior to ensure that the popover is not dismissed by taps outside the popover controller.
- (UIModalPresentationStyle) modalPresentationStyle
The presentation style for modally presented view controllers. The presentation style determines how a modally presented view controller is displayed onscreen. On iPhone and iPod touch, modal view controllers are always presented full-screen, but on iPad there are several different presentation options. For a list of possible presentation styles, and their compatibility with the available transition styles, see the “Presentation Styles” constant descriptions.
- (UIModalTransitionStyle) modalTransitionStyle
The transition style to use when presenting the receiver. This property determines how the view controller’s is animated onscreen when it is presented using the presentViewController:animated:completion: method. To change the transition type, you must set this property before presenting the view controller. The default value for this property is UIModalTransitionStyleCoverVertical. For a list of possible transition styles, and their compatibility with the available presentation styles, see the “Presentation Transition Styles” constant descriptions.
- (UINavigationController) navigationController (readonly)
The nearest ancestor in the view controller hierarchy that is a navigation controller. (read-only) If the receiver or one of its ancestors is a child of a navigation controller, this property contains the owning navigation controller. This property is nil if the view controller is not embedded inside a navigation controller.
- (UINavigationItem) navigationItem (readonly)
The navigation item used to represent the view controller in a parent’s navigation bar. (read-only) This is a unique instance of UINavigationItem created to represent the view controller when it is pushed onto a navigation controller. The first time the property is accessed, the UINavigationItem object is created. Therefore, you shouldn’t access this property if you are not using a navigation controller to display the view controller. To ensure the navigation item is configured, you can either override this property and add code to create the bar button items when first accessed or create the items in your view controller’s initialization code.Avoid tying the creation of bar button items in your navigation item to the creation of your view controller’s view. The navigation item of a view controller may be retrieved independently of the view controller’s view. For example, when pushing two view controllers onto a navigation stack, the topmost view controller becomes visible, but the other view controller’s navigation item may be retrieved in order to present its back button. The default behavior is to create a navigation item that displays the view controller’s title.
- (NSBundle) nibBundle (readonly)
Return the name of the receiver’s nib bundle if it exists. (read-only)
- (String) nibName (readonly)
Return the name of the receiver’s nib file, if one was specified. (read-only) This property contains the value specified at initialization time to the initWithNibName:bundle: method. The value of this property may be nil.If you use a nib file to store your view controller’s view, it is recommended that you specify that nib file explicitly when initializing your view controller. However, if you do not specify a nib name, and do not override the loadView method in your custom subclass, the view controller searches for a nib file using other means. Specifically, it looks for a nib file with an appropriate name (without the .nib extension) and loads that nib file whenever its view is requested. Specifically, it looks (in order) for a nib file with one of the following names:If the view controller class name ends with the word “Controller”, as in MyViewController, it looks for a nib file whose name matches the class name without the word “Controller”, as in MyView.nib. It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is MyViewController, it looks for a MyViewController.nib file.
- (UIViewController) parentViewController (readonly)
The parent view controller of the recipient. (read-only) If the recipient is a child of a container view controller, this property holds the view controller it is contained in. If the recipient has no parent, the value in this property is nil.Prior to iOS 5.0, if a view did not have a parent view controller and was being presented, the presenting view controller would be returned. On iOS 5, this behavior no longer occurs. Instead, use the presentingViewController property to access the presenting view controller.
- (UIViewController) presentedViewController (readonly)
The view controller that is presented by this view controller, or one of its ancestors in the view controller hierarchy. (read-only)
- (UIViewController) presentingViewController (readonly)
The view controller that presented this view controller. (read-only) If the view controller that received this message is presented by another view controller, this property holds the view controller that is presenting it. If the view controller is not presented, but one of its ancestors is being presented, this property holds the view controller presenting the nearest ancestor. If neither the view controller nor any of its ancestors are being presented, this property holds nil.
- (Boolean) providesPresentationContextTransitionStyle
A Boolean value that indicates whether the view controller defines the transition style for view controllers it presents. When a view controller provides a presentation context to a presented view controller, it can choose to override the transition style of the presented view controller and substitute its own. If the value of this property is YES, then its own modal transition style is used whenever it provides the context for a presented view controller. If the value of this property is NO, then the modal transition style of the presented view controller’s modal transition style is used. The default value is NO.
- (Class<UIViewControllerRestoration>) restorationClass
The class responsible for recreating this view controller when restoring the app’s state. If a view controller has an associated restoration class, the viewControllerWithRestorationIdentifierPath:coder: method of that class is called during state restoration. That method is responsible for returning the view controller object that matches the indicated view controller. If you do not specify a restoration class for your view controller, the state restoration engine asks your app delegate to provide the view controller object instead.The restoration class must conform to the UIViewControllerRestoration protocol.
- (String) restorationIdentifier
The identifier that determines whether the view controller supports state restoration. This property indicates whether the view controller and its contents should be preserved and is used to identify the view controller during the restoration process. The value of this property is nil by default, which indicates that the view controller should not be saved. Assigning a string object to the property lets the system know that the view controller should be saved. In addition, the contents of the string are your way to identify the purpose of the view controller. During subsequent launches, UIKit asks your app for help in recreating the view controllers that were installed the last time your app ran. When it asks for a specific view controller, UIKit provides your app with this restoration identifier and the restoration identifiers of any parent view controllers in the view controller hierarchy. Your app must use this information to create or locate the appropriate view controller object. Important: Simply setting the value of this property is not enough to ensure that the view controller is preserved and restored. All parent view controllers must also have a restoration identifier. For more information about the preservation and restoration process, see View Controller Programming Guide for iOS.
- (UISearchDisplayController) searchDisplayController (readonly)
The search display controller associated with the view controller. (read-only) This property reflects the value of the searchDisplayController outlet that you set in Interface Builder. If you create your search display controller programmatically, this property is set automatically by the search display controller when it is initialized.
- (UISplitViewController) splitViewController (readonly)
The nearest ancestor in the view controller hierarchy that is a split view controller. (read-only) If the receiver or one of its ancestors is a child of a split view controller, this property contains the owning split view controller. This property is nil if the view controller is not embedded inside a split view controller.
- (UIStoryboard) storyboard (readonly)
The storyboard from which the view controller originated. (read-only) If the view controller was not instantiated from a storyboard, this property is nil.
- (UITabBarController) tabBarController (readonly)
The nearest ancestor in the view controller hierarchy that is a tab bar controller. (read-only) If the receiver or one of its ancestors is a child of a tab bar controller, this property contains the owning tab bar controller. This property is nil if the view controller is not embedded inside a tab bar controller.
- (UITabBarItem) tabBarItem
The tab bar item that represents the view controller when added to a tab bar controller. This is a unique instance of UITabBarItem created to represent the view controller when it is a child of a tab bar controller. The first time the property is accessed, the UITabBarItem is created. Therefore, you shouldn’t access this property if you are not using a tab bar controller to display the view controller. To ensure the tab bar item is configured, you can either override this property and add code to create the bar button items when first accessed or create the items in your view controller’s initialization code.The default value is a tab bar item that displays the view controller’s title.
- (String) title
A localized string that represents the view this controller manages. Subclasses should set the title to a human-readable string that represents the view to the user.
- (Array) toolbarItems
The toolbar items associated with the view controller. This property contains an array of UIBarButtonItem objects and works in conjunction with a UINavigationController object. If this view controller is embedded inside a navigation controller interface, and the navigation controller displays a toolbar, this property identifies the items to display in that toolbar. You can set the value of this property explicitly or use the setToolbarItems:animated: method to animate changes to the visible set of toolbar items.
- (UIView) view
The view that the controller manages. 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 loadView 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 addChildViewController: 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 isViewLoaded method to determine if the view is currently in memory. Unlike this property, the isViewLoaded property does not force the loading of the view if it is not currently in memory. The UIViewController 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 “The View Controller Life Cycle”.
- (Boolean) wantsFullScreenLayout
A Boolean value indicating whether the view should underlap the status bar. When a view controller presents its view, it normally shrinks that view so that its frame does not overlap the device’s status bar. Setting this property to YES causes the view controller to size its view so that it fills the entire screen, including the area under the status bar. (Of course, for this to happen, the window hosting the view controller must itself be sized to fill the entire screen, including the area underneath the status bar.) You would typically set this property to YES in cases where you have a translucent status bar and want your view’s content to be visible behind that view.If this property is YES, the view is not resized in a way that would cause it to underlap a tab bar but is resized to underlap translucent toolbars. Regardless of the value of this property, navigation controllers always allow views to underlap translucent navigation bars.The default value of this property is NO, which causes the view to be laid out so it does not underlap the status bar.
Class Method Details
+ (Object) attemptRotationToDeviceOrientation
Attempts to rotate all windows to the orientation of the device. Some view controllers may want to use app-specific conditions to determine what interface orientations are supported. If your view controller does this, when those conditions change, your app should call this class method. The system immediately attempts to rotate to the new orientation.
Instance Method Details
- (Object) addChildViewController(childController)
Adds the given view controller as a child. If the new child view controller is already the child of a container view controller, it is removed from that container before being added.This method is only intended to be called by an implementation of a custom container view controller. If you override this method, you must call super in your implementation.
- (Object) beginAppearanceTransition(isAppearing, animated:animated)
Tells a child controller its appearance is about to change. If you are implementing a custom container controller, use this method to tell the child that its views are about to appear or disappear. Do not invoke viewWillAppear:, viewWillDisappear:, viewDidAppear:, or viewDidDisappear: directly.
- (Boolean) canPerformUnwindSegueAction(action, fromViewController:fromViewController, withSender:sender)
Called on a view controller to determine whether it wants to respond to an unwind action. This method is called when the system is attempting to find a view controller to handle an unwind action. Your custom view controller should implement this method to tell the system that it wants to support an unwind action.If your view controller returns YES, then a series of steps are performed:The target view controller’s container invokes its segueForUnwindingToViewController:fromViewController:identifier: method to create a segue to unwind the view controller state.The action method is called on the target view controller.The segue is triggered to perform the segue.new segue is created to transition from the initiating view controller to your view controller. After the segue is created, your action is called and then the segue is invoked,
- (Object) decodeRestorableStateWithCoder(coder)
Decodes and restores state-related information for the view controller. If your app supports state restoration, you should override this method for any view controllers for which you also overrode the encodeRestorableStateWithCoder: method. Your implementation of this method should use any saved state information to restore the view controller to its previous configuration. If your encodeRestorableStateWithCoder: method called super, this method should similarly call super at some point in its implementation.
- (Object) didMoveToParentViewController(parent)
Called after the view controller is added or removed from a container view controller. Your view controller can override this method when it wants to react to being added to a container.If you are implementing your own container view controller, it must call the didMoveToParentViewController: method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the addChildViewController: method.The removeFromParentViewController method automatically calls the didMoveToParentViewController: method of the child view controller after it removes the child.
- (Object) didReceiveMemoryWarning
Sent to the view controller when the app receives a memory warning. Your app never calls this method directly. Instead, this method is called when the system determines that the amount of available memory is low.You can override this method to release any additional memory used by your view controller. If you do, your implementation of this method must call the super implementation at some point.
- (Object) didRotateFromInterfaceOrientation(fromInterfaceOrientation)
Sent to the view controller after the user interface rotates. Subclasses may override this method to perform additional actions immediately after the rotation. For example, you might use this method to reenable view interactions, start media playback again, or turn on expensive drawing or live updates. By the time this method is called, the interfaceOrientation property is already set to the new orientation. This method is called regardless of whether your code performs one-step or two-step rotations.
- (Boolean) disablesAutomaticKeyboardDismissal
Returns a Boolean indicating whether the current input view is dismissed automatically when changing controls. Override this method in a subclass to allow or disallow the dismissal of the current input view (usually the system keyboard) when changing from a control that wants the input view to one that does not. Under normal circumstances, when the user taps a control that requires an input view, the system automatically displays that view. Tapping in a control that does not want an input view subsequently causes the current input view to be dismissed but may not in all cases. You can override this method in those outstanding cases to allow the input view to be dismissed or use this method to prevent the view from being dismissed in other cases.The default implementation of this method returns YES when the modal presentation style of the view controller is set to UIModalPresentationFormSheet and returns NO for other presentation styles. Thus, the system normally does not allow the keyboard to be dismissed for modal forms.
- (Object) dismissViewControllerAnimated(flag, completion:completion)
Dismisses the view controller that was presented by the receiver. The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.If you want to retain a reference to the receiver’s presented view controller, get the value in the presentedViewController property before calling this method.The completion handler is called after the viewDidDisappear: method is called on the presented view controller.
- (UIBarButtonItem) editButtonItem
Returns a bar button item that toggles its title and associated state between Edit and Done. If one of the custom views of the navigationItem property is set to the returned object, the associated navigation bar displays an Edit button if editing is NO and a Done button if editing is YES. The default button action invokes the setEditing:animated: method.
- (Object) encodeRestorableStateWithCoder(coder)
Encodes state-related information for the view controller. Subclasses can override this method and use it to save any view-controller specific state information. When deciding what data to save, write the smallest amount of data needed to restore the view controller to its current configuration. The information you save should be data that you could not easily recreate, such as the user’s current selection. You might also save references to any data objects that the view controller was using, but never write the data objects themselves to the coder. Instead, store enough information so that you can retrieve the data objects from your app’s main data structures again.Important: This method is not a substitute for saving your app’s data structures persistently to disk. You should continue to save your app’s actual data to iCloud or the local file system using existing techniques. This method is intended only for saving configuration state or other information related to your app’s user interface. You should consider any data you write to the coder as purgeable and be prepared for it to be unavailable during subsequent launches.It is strongly recommended that you call super at some point during your implementation to give parent classes an opportunity to save information too. The UIViewController class saves a reference to the presented view controller and the storyboard (if any) that was used to create the view controller. The view controller also asks the views in its view hierarchy to save out any relevant information. However, this class does not automatically save references to any contained child view controllers. If you are implementing a custom container view controller, you must encode the child view controller objects yourself if you want them to be preserved.Your implementation of this method can encode other restorable view and view controller objects that it needs to reference. Encoding a restorable view or view controller writes that object’s restoration identifier to the coder. That identifier is used during the decode process to locate the new version of the object. If the view or view controller defines its own own version of this method, that method is also called at some point so that the object can encode its own state. Apart from views and view controllers, other objects follow the normal serialization process and must adopt the NSCoding protocol before they can be encoded. Encoding such objects embeds the object’s contents in the archive directly. During the decode process, a new object is created and initialized with the data from the archive.
- (Object) endAppearanceTransition
Tells a child controller its appearance has changed. If you are implementing a custom container controller, use this method to tell the child that the view transition is complete.
- (Object) initWithNibName(nibName, bundle:nibBundle)
Returns a newly initialized view controller with the nib file in the specified bundle. This is the designated initializer for this class.The nib file you specify is not loaded right away. It is loaded the first time the view controller’s view is accessed. If you want to perform additional initialization after the nib file is loaded, override the viewDidLoad method and perform your tasks there.If you specify nil for the nibName parameter and you do not override the loadView method, the view controller searches for a nib file using other means. See nibName.If your app uses a storyboard to define a view controller and its associated views, your app never initializes objects of that class directly. Instead, view controllers are either instantiated by the storyboard—either automatically by iOS when a segue is triggered or programmatically when your app calls the storyboard object’s instantiateViewControllerWithIdentifier: method. When instantiating a view controller from a storyboard, iOS initializes the new view controller by calling its initWithCoder: method instead. iOS automatically sets the nibName property to a nib file stored inside the storyboard.For more information about how a view controller loads its view, see “The View Controller Life Cycle”.
- (Boolean) isBeingDismissed
Returns a Boolean value that indicates whether the view controller is in the process of being dismissed by one of its ancestors. This method returns YES only when called from inside the following methods:viewWillDisappear:viewDidDisappear:
- (Boolean) isBeingPresented
Returns a Boolean value that indicates view controller is in the process of being presented by one of its ancestors. This method returns YES only when called from inside the following methods:viewWillAppear:viewDidAppear:
- (Boolean) isMovingFromParentViewController
Returns a Boolean value that indicates that the view controller is in the process of being removed from its parent. This method returns YES only when called from inside the following methods:viewWillDisappear:viewDidDisappear:
- (Boolean) isMovingToParentViewController
Returns a Boolean value that indicates that the view controller is in the process of being added to a parent. This method returns YES only when called from inside the following methods:viewWillAppear:viewDidAppear:
- (Boolean) isViewLoaded
Returns a Boolean value indicating whether the view is currently loaded into memory. Calling this method reports whether the view is loaded. Unlike the view property, it does not attempt to load the view if it is not already in memory.
- (Object) loadView
Creates the view that the controller manages. You should never call this method directly. The view controller calls this method when its view property is requested but is currently nil. This method loads or creates a view and assigns it to the view property.If the view controller has an associated nib file, this method loads the view from the nib file. A view controller has an associated nib file if the nibName property returns a non-nil value, which occurs if the view controller was instantiated from a storyboard, if you explicitly assigned it a nib file using the initWithNibName:bundle: method, or if iOS finds a nib file in the app bundle with a name based on the view controller’s class name. If the view controller does not have an associated nib file, this method creates a plain UIView object instead.If you use Interface Builder to create your views and initialize the view controller, you must not override this method.You can override this method in order to create your views manually. If you choose to do so, assign the root view of your view hierarchy to the view property. The views you create should be unique instances and should not be shared with any other view controller object. Your custom implementation of this method should not call super.If you want to perform any additional initialization of your views, do so in the viewDidLoad method.
- (Object) performSegueWithIdentifier(identifier, sender:sender)
Initiates the segue with the specified identifier from the view controller’s storyboard file. Apps normally do not need to trigger segues directly. Instead, you configure an object in Interface Builder associated with the view controller, such as a control embedded in its view hierarchy, to trigger the segue. However, you can call this method to trigger a segue programmatically, perhaps in response to some action that cannot be specified in the storyboard resource file. For example, you might call it from a custom action handler used to process shake or accelerometer events.The view controller that receives this message must have been loaded from a storyboard. If the view controller does not have an associated storyboard, perhaps because you allocated and initialized it yourself, this method throws an exception.
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
Returns the interface orientation to use when presenting the view controller. The system calls this method when presenting the view controller full screen. You implement this method when your view controller supports two or more orientations but the content appears best in one of those orientations.If your view controller implements this method, then when presented, its view is shown in the preferred orientation (although it can later be rotated to another supported rotation). If you do not implement this method, the system presents the view controller using the current orientation of the status bar.
- (Object) prepareForSegue(segue, sender:sender)
Notifies the view controller that a segue is about to be performed. The default implementation of this method does nothing. Your view controller overrides this method when it needs to pass relevant data to the new view controller. The segue object describes the transition and includes references to both view controllers involved in the segue.Because segues can be triggered from multiple sources, you can use the information in the segue and sender parameters to disambiguate between different logical paths in your app. For example, if the segue originated from a table view, the sender parameter would identify the table view cell that the user tapped. You could use that information to set the data on the destination view controller.
- (Object) presentViewController(viewControllerToPresent, animated:flag, completion:completion)
Presents a view controller. On iPhone and iPod touch, the presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.This method sets the presentedViewController property to the specified view controller, resizes that view controller’s view and then adds the view to the view hierarchy. The view is animated onscreen according to the transition style specified in the modalTransitionStyle property of the presented view controller.The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- (Object) removeFromParentViewController
Removes the receiver from its parent in the view controller hierarchy. This method is only intended to be called by an implementation of a custom container view controller. If you override this method, you must call super in your implementation.
- (UIView) rotatingFooterView
Returns the footer view to transition during an interface orientation change. In most cases, the header view is the navigation bar and the footer view is the tab bar. If you are implementing this method in a custom view controller that has its own custom footer view, you can override this method to return that footer view. The view returned from this method should already be part of your view controller’s view hierarchy. You are responsible for adjusting the size and position of the returned view to match the target orientation. You would make such a change in your view controller’s rotation methods, such as the willAnimateRotationToInterfaceOrientation:duration: method.
- (UIView) rotatingHeaderView
Returns the header view to transition during an interface orientation change. In most cases, the header view is the navigation bar and the footer view is the tab bar. If you are implementing this method in a custom view controller that has its own custom header view, you can override this method to return that header view. The view returned from this method should already be part of your view controller’s view hierarchy. You are responsible for adjusting the size and position of the returned view to match the target orientation. You would make such a change in your view controller’s rotation methods, such as the willAnimateRotationToInterfaceOrientation:duration: method.
- (UIStoryboardSegue) segueForUnwindingToViewController(toViewController, fromViewController:fromViewController, identifier:identifier)
Called when an unwind segue action needs to transition between two view controllers. If you implement a custom container view controller that also uses segue unwinding, you must override this method. Your method implementation should instantiate and return a custom segue object that performs whatever animation and other steps that are necessary to unwind the view controllers.
- (Object) setEditing(editing, animated:animated)
Sets whether the view controller shows an editable view. Subclasses that use an edit-done button must override this method to change their view to an editable state if editing is YES and a non-editable state if it is NO. This method should invoke super’s implementation before updating its view.
- (Object) setToolbarItems(toolbarItems, animated:animated)
Sets the toolbar items to be displayed along with the view controller. View controllers that are managed by a navigation controller can use this method to specify toolbar items for the navigation controller’s built-in toolbar. You can set the toolbar items for your view controller before your view controller is displayed or after it is already visible.
- (Boolean) shouldAutomaticallyForwardAppearanceMethods
Returns a Boolean value indicating whether appearance methods are forwarded to child view controllers. This method is called to determine whether to automatically forward appearance-related containment callbacks to child view controllers.The default implementation returns YES. Subclasses of the UIViewController class that implement containment logic may override this method to control how these methods are forwarded. If you override this method and return NO, you are responsible for telling the child when its views are going to appear or disappear. You do this by calling the child view controller’s beginAppearanceTransition:animated: and endAppearanceTransition methods.
- (Boolean) shouldAutomaticallyForwardRotationMethods
Returns a Boolean value indicating whether rotation methods are forwarded to child view controllers. This method is called to determine whether to automatically forward rotation-related containment callbacks to child view controllers.The default implementation returns YES. Subclasses of the UIViewController class that implement containment logic may override this method to control how these methods are forwarded. If you override this method and return NO, you are responsible for forwarding the following methods to child view controllers at the appropriate times:willRotateToInterfaceOrientation:duration:willAnimateRotationToInterfaceOrientation:duration:didRotateFromInterfaceOrientation:
- (Boolean) shouldAutorotate
Returns whether the view controller’s contents should auto rotate.
- (Boolean) shouldPerformSegueWithIdentifier(identifier, sender:sender)
Determines whether the seque with the specified identifier should be triggered. Your view controller overrides this method when it wants to control whether a segue should be performed. The default behavior is to permit all segues to be triggered.
- (Integer) supportedInterfaceOrientations
Returns all of the interface orientations that the view controller supports. When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window. If the view controller supports the new orientation, the window and view controller are rotated to the new orientation. This method is only called if the view controller’s shouldAutorotate method returns YES.Override this method to report all of the orientations that the view controller supports. The default values for a view controller’s supported interface orientations is set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.The system intersects the view controller’s supported orientations with the app’s supported orientations (as determined by the Info.plist file or the app delegate’s application:supportedInterfaceOrientationsForWindow: method) to determine whether to rotate.
- (Object) transitionFromViewController(fromViewController, toViewController:toViewController, duration:duration, options:options, animations:animations, completion:completion)
Transitions between two of the view controller’s child view controllers. This method adds the second view controller’s view to the view hierarchy and then performs the animations defined in your animations block. After the animation completes, it removes the first view controller’s view from the view hierarchy.This method is only intended to be called by an implementation of a custom container view controller. If you override this method, you must call super in your implementation.
- (Object) updateViewConstraints
Called when the view controller’s view needs to update its constraints. You may override this method in a subclass in order to add constraints to the view or its subviews. If you override this method, your implementation must invoke super’s implementation.
- (UIViewController) viewControllerForUnwindSegueAction(action, fromViewController:fromViewController, withSender:sender)
Called when an unwind segue action wants to search a container’s children for a view controller to handle the unwind action. A custom container view controller should override this method and use it to search its children for a view controller to handle the unwind action. It does this by invoking the canPerformUnwindSegueAction:fromViewController:withSender: method on each child. If a view controller wants to handle the action, your method should return it. If none of the container’s children want to handle the unwind action, invoke the super’s implementation and return the result of that method.
- (Object) viewDidAppear(animated)
Notifies the view controller that its view was added to a view hierarchy. You can override this method to perform additional tasks associated with presenting the view. If you override this method, you must call super at some point in your implementation. Note: If a view controller is presented by a view controller inside of a popover, this method is not invoked on the presenting view controller after the presented controller is dismissed.
- (Object) viewDidDisappear(animated)
Notifies the view controller that its view was removed from a view hierarchy. You can override this method to perform additional tasks associated with dismissing or hiding the view. If you override this method, you must call super at some point in your implementation.
- (Object) viewDidLayoutSubviews
Notifies the view controller that its view just laid out its subviews. When a view’s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes after the view lays out its subviews. The default implementation of this method does nothing.
- (Object) viewDidLoad
Called after the controller’s view is loaded into memory. This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.
- (Object) viewWillAppear(animated)
Notifies the view controller that its view is about to be added to a view hierarchy. This method is called before the receiver’s view is about to be added to a view hierarchy and before any animations are configured for showing the view. You can override this method to perform custom tasks associated with displaying the view. For example, you might use this method to change the orientation or style of the status bar to coordinate with the orientation or style of the view being presented. If you override this method, you must call super at some point in your implementation. For more information about the how views are added to view hierarchies by a view controller, and the sequence of messages that occur, see “Responding to Display-Related Notifications”. Note: If a view controller is presented by a view controller inside of a popover, this method is not invoked on the presenting view controller after the presented controller is dismissed.
- (Object) viewWillDisappear(animated)
Notifies the view controller that its view is about to be removed from a view hierarchy. This method is called in response to a view being removed from a view hierarchy. This method is called before the view is actually removed and before any animations are configured.Subclasses can override this method and use it to commit editing changes, resign the first responder status of the view, or perform other relevant tasks. For example, you might use this method to revert changes to the orientation or style of the status bar that were made in the viewDidDisappear: method when the view was first presented. If you override this method, you must call super at some point in your implementation.
- (Object) viewWillLayoutSubviews
Notifies the view controller that its view is about to layout its subviews. When a view’s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes before the view lays out its subviews. The default implementation of this method does nothing.
- (Object) willAnimateRotationToInterfaceOrientation(interfaceOrientation, duration:duration)
Sent to the view controller before performing a one-step user interface rotation. This method is called from within the animation block used to rotate the view. You can override this method and use it to configure additional animations that should occur during the view rotation. For example, you could use it to adjust the zoom level of your content, change the scroller position, or modify other animatable properties of your view.Note: The animations used to slide the header and footer views in and out of position are performed in separate animation blocks.By the time this method is called, the interfaceOrientation property is already set to the new orientation, and the bounds of the view have been changed. Thus, you can perform any additional layout required by your views in this method.
- (Object) willMoveToParentViewController(parent)
Called just before the view controller is added or removed from a container view controller. Your view controller can override this method when it needs to know that it has been added to a container.If you are implementing your own container view controller, it must call the willMoveToParentViewController: method of the child view controller before calling the removeFromParentViewController method, passing in a parent value of nil.When your custom container calls the addChildViewController: method, it automatically calls the willMoveToParentViewController: method of the view controller to be added as a child before adding it.
- (Object) willRotateToInterfaceOrientation(toInterfaceOrientation, duration:duration)
Sent to the view controller just before the user interface begins rotating. Subclasses may override this method to perform additional actions immediately prior to the rotation. For example, you might use this method to disable view interactions, stop media playback, or temporarily turn off expensive drawing or live updates. You might also use it to swap the current view for one that reflects the new interface orientation. When this method is called, the interfaceOrientation property still contains the view’s original orientation.This method is called regardless of whether your code performs one-step or two-step rotations.