UISplitViewControllerDelegate Protocol Reference

Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.2 and later.
Companion guide
Declared in
UISplitViewController.h
Related sample code

Overview

The UISplitViewControllerDelegate protocol defines methods that allow you to manage changes to the visible view controllers in a split view controller. When the split view controller rotates between portrait and landscape orientations, it hides or shows the first view controller in its array of view controllers. When the view controller is hidden, it is standard practice to add a button to the toolbar of the remaining view controller that, when tapped, displays the hidden view controller in a popover. The methods of this protocol provide you with the information you need to add and remove this button at the appropriate times.

For more information about the UISplitViewController class, see UISplitViewController Class Reference.

Tasks

Showing and Hiding View Controllers

Overriding View Rotation Settings

Instance Methods

splitViewController:popoverController:willPresentViewController:

Tells the delegate that the hidden view controller is about to be displayed in a popover.

- (void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController
Parameters
svc

The split view controller that owns the hidden view controller.

pc

The popover controller that is about to display the view controller.

aViewController

The view controller to be displayed in the popover.

Discussion

The toolbar button you add to your user interface facilitates the display of the hidden view controller in response to user taps. When the user taps that button, the split view controller calls this method. You can use this method to perform any additional steps prior to displaying the currently hidden view controller.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISplitViewController.h

splitViewController:shouldHideViewController:inOrientation:

Asks the delegate whether the first view controller should be hidden for the specified orientation.

- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
Parameters
svc

The split view controller that owns the first view controller.

vc

The first view controller in the array of view controllers.

orientation

The orientation being considered.

Return Value

YES if the view controller should be hidden in the specified orientation or NO if it should be visible. If you do not implement this method, a value of YES is assumed for portrait orientations and NO is assumed for landscape orientations.

Discussion

The split view controller calls this method only for the first child view controller in its array. The second view controller always remains visible regardless of the orientation.

Prior to iOS 5.0, the first view controller was always hidden in portrait orientations and always shown in landscape orientations. If you do not implement this method in your delegate object, that default behavior remains in effect.

Availability
  • Available in iOS 5.0 and later.
Declared In
UISplitViewController.h

splitViewController:willHideViewController:withBarButtonItem:forPopoverController:

Tells the delegate that the specified view controller is about to be hidden.

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
Parameters
svc

The split view controller that owns the specified view controller.

aViewController

The view controller being hidden.

barButtonItem

A button you can add to your toolbar.

pc

The popover controller that uses taps in barButtonItem to display the specified view controller.

Discussion

When the split view controller rotates from a landscape to portrait orientation, it normally hides one of its view controllers. When that happens, it calls this method to coordinate the addition of a button to the toolbar (or navigation bar) of the remaining custom view controller. If you want the soon-to-be hidden view controller to be displayed in a popover, you must implement this method and use it to add the specified button to your interface.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISplitViewController.h

splitViewController:willShowViewController:invalidatingBarButtonItem:

Tells the delegate that the specified view controller is about to be shown again.

- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)button
Parameters
svc

The split view controller that owns the specified view controller.

aViewController

The view controller being hidden.

button

The button used to display the view controller while it was hidden.

Discussion

When the view controller rotates from a portrait to landscape orientation, it shows its hidden view controller once more. If you added the specified button to your toolbar to facilitate the display of the hidden view controller in a popover, you must implement this method and use it to remove that button.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISplitViewController.h

splitViewControllerPreferredInterfaceOrientationForPresentation:

Returns the preferred orientation for presentation of the split view controller, as determined by the delegate.

- (UIInterfaceOrientation)splitViewControllerPreferredInterfaceOrientationForPresentation:(UISplitViewController *)splitViewController;
Parameters
splitViewController

The split view controller.

Return Value

The preferred orientation for presenting the split view controller.

Availability
  • Available in iOS 7.0 and later.
Declared In
UISplitViewController.h

splitViewControllerSupportedInterfaceOrientations:

Returns the complete set of supported interface orientations for the split view controller, as determined by the delegate.

- (NSUInteger)splitViewControllerSupportedInterfaceOrientations:(UISplitViewController *)splitViewController;
Parameters
splitViewController

The split view controller.

Return Value

One of the UIInterfaceOrientationMask constants that represents the set of interface orientations supported by the split view controller.

Availability
  • Available in iOS 7.0 and later.
Declared In
UISplitViewController.h