Handling Popover Controllers During Orientation Changes
Q: How do I handle popover controllers when the device orientation changes?
A: How do I handle popover controllers when the device orientation changes?
When showing a popover controller, there are times when you will need to handle how the popover controller appears after a change in device orientation.
Situations when handling is required:
If the popover controller is presented from a target rectangle using the
–presentPopoverFromRect:inView:permittedArrowDirections:animated:
method of UIPopoverController.If the popover controller is presented from a bar button item that is removed after the rotation has finished.
Presenting a popover controller from a target rectangle after an orientation change
In the
-didRotateFromInterfaceOrientation:
method of UIApplication, present the popover controller again after the rotation has finished.Listing 1 Presenting a popover controller from a target rectangle after the rotation has finished.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [aPopover presentPopoverFromRect:targetRect.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; }
Do not present more than one popover controller at a time. For more information on the proper usage of UIPopoverController, read the Popover section in the in the iOS Human Interface Guidelines.
Do not use
self.popovercontroller
for a custom popover controller, if you are using a split-view controller. The default popover controller should be reserved for the master list view controller.
Document Revision History
Date | Notes |
---|---|
2010-12-10 | Updated to reflect consolidated iPad/iPhone Human Interface Guidelines. |
2010-05-18 | Removed situations where handling of popover controllers was not required. |
2010-05-17 | New document that shows best practices for handling popover controllers during device orientation changes. |
Copyright © 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-12-10