Not interfering with adaptive presentation

Number:rdar://23260682 Date Originated:26-Oct-2015 06:23 PM
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification: Reproducible:
There is no way to implement 
adaptivePresentationStyleForPresentationController:traitCollection: in UIAdaptivePresentationControllerDelegate that results in the same behaviour as if this method was not implemented. We want to make a configurable object that sometimes returns UIModalPresentationNone and sometimes does not interfere with the presentation.

Steps to Reproduce:
1. Set a view controller’s presentationController’s delegate to something
2. Present the view controller
3. In the delegate, implement adaptivePresentationStyleForPresentationController:traitCollection: but try not to change the presentation style (assume the object is reusable and you don’t know what the presentation style should be).

Expected Results:
It would be nice if it was possible to implement this method without losing access to the default adaptivity behaviour.

Actual Results:
There is no simple way to make the presentation behave as if this delegate method was not implemented.

iOS 9.1, Xcode 7.1 (7B91b)

I can think of two workarounds, which both make some assumptions about the implementation of UIKit.

1. Loop back to the presentation controller, temporarily unsetting the delegate to avoid infinite recursion.

presentationController.delegate = nil;
UIModalPresentationStyle const style = [presentationController adaptivePresentationStyleForTraitCollection:traitCollection];
presentationController.delegate = self;
return style;

2. Conditionally implement respondsToSelector:. Assumes the check is made every time rather than just when the delegate is set.

- (BOOL)respondsToSelector:(SEL)selector {
    if (selector == @selector(adaptivePresentationStyleForPresentationController:traitCollection:)) {
        return <Should we interfere with the presentation?>

    return [super respondsToSelector:selector];

If either of these approaches is recommended, please could this be documented?




Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!