iOS Developer Library

Developer

UIKit Framework Reference UIPopoverControllerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIPopoverControllerDelegate

The UIPopoverControllerDelegate protocol defines the methods you can implement for the delegate of a UIPopoverController object. Popover controllers notify their delegate whenever user interactions would cause the dismissal of the popover and, in some cases, give the user a chance to prevent that dismissal.

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

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 3.2 and later.
  • Tells the delegate that the popover controller needs to change the popover’s location in its view.

    Declaration

    Swift

    optional func popoverController(_ popoverController: UIPopoverController, willRepositionPopoverToRect rect: UnsafeMutablePointer<CGRect>, inView view: AutoreleasingUnsafeMutablePointer<UIView?>)

    Objective-C

    - (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView **)view

    Parameters

    popoverController

    The popover controller changing the position of its content.

    rect

    On input, the proposed rectangle for the popover. This popover is in the coordinate space of the view in the view parameter. If you want to propose a different rectangle for the popover, put the new value in this parameter.

    view

    On input, the proposed view for containing the popover. If you want to propose a different view for the popover, put the new view in this parameter.

    Discussion

    For popovers that were presented using the presentPopoverFromRect:inView:permittedArrowDirections:animated: method, the popover controller calls this method when the interface orientation changes. Your delegate can use this method to adjust the proposed position of the popover. The popover controller does not call this method if you presented the popover from a bar button item.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Asks the delegate if the popover should be dismissed.

    Declaration

    Swift

    optional func popoverControllerShouldDismissPopover(_ popoverController: UIPopoverController) -> Bool

    Objective-C

    - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController

    Parameters

    popoverController

    The popover controller to be dismissed.

    Return Value

    YEStrue if the popover should be dismissed or NOfalse if it should remain visible.

    Discussion

    This method is called in response to user-initiated attempts to dismiss the popover. It is not called when you dismiss the popover using the dismissPopoverAnimated: method of the popover controller.

    If you do not implement this method in your delegate, the default return value is assumed to be YEStrue.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Tells the delegate that the popover was dismissed.

    Declaration

    Swift

    optional func popoverControllerDidDismissPopover(_ popoverController: UIPopoverController)

    Objective-C

    - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController

    Parameters

    popoverController

    The popover controller that was dismissed.

    Discussion

    The popover controller does not call this method in response to programmatic calls to the dismissPopoverAnimated: method. If you dismiss the popover programmatically, you should perform any cleanup actions immediately after calling the dismissPopoverAnimated: method.

    You can use this method to incorporate any changes from the popover’s content view controller back into your application. If you do not plan to use the object in the popoverController parameter again, it is safe to release it from this method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.