17

Compiling my iPad app against the 5.1 SDK (release version) causes UIPopoverController to show itself using the new "slide in" from the left presentation. This completely breaks my popover presentation, which relied on having a "black" style header and a certain height. I've tried setting presentsWithGesture to NO, but that only seems to disable the swipe gesture, and doesn't stop the presentation style.

This same app, without being recompiled, but running on iOS 5.1, uses the old popover presentation style. So I know iOS 5.1 still supports the backwards-compatible method. How can I choose to activate the old presentation of the popover?

This is really critical to my app, unfortunately.

Failing that, is there any way to get the "black" style header on the new popovers?


Although I have a UISplitViewController in my app, it is not responsible for showing the popover. Instead, I'm using this code:

   [self.popoverController presentPopoverFromRect:ipadButtonMenu.frame
                                           inView:self.view
                         permittedArrowDirections:UIPopoverArrowDirectionUp
                                         animated:YES];

This question is a cross-post from the Apple Developer Forums here. I'm hoping somebody has the answer.


Expected presentation: enter image description here

Presentation after compiling under iOS 5.1 SDK: enter image description here

Piotr Byzia
  • 3,363
  • 7
  • 42
  • 62
Jeremy Fuller
  • 3,391
  • 1
  • 32
  • 27
  • That is some mighty fine UI designin' my friend! Have you had a chance to clean your build and recompile from scratch? I would file a radar, as twitter seems to be blowing up with the same problem you are facing. – CodaFi Mar 08 '12 at 04:04
  • Yes, clean/rebuild doesn't seem to affect it. Anyone specific on Twitter you're seeing talk about it? – Jeremy Fuller Mar 08 '12 at 04:06
  • A short summation: https://mobile.twitter.com/nimaa/status/156521684512415746 – CodaFi Mar 08 '12 at 04:07
  • I'll bet you it's declared wrong. I just noticed the documentation only declares the property as @property (nonatomic) BOOL presentsWithGesture; I don't see any assign in there... – CodaFi Mar 08 '12 at 04:16
  • Well, the documentation doesn't necessarily say that `presentsWithGesture` is supposed to modify the presentation style, just the gesture itself. But it's the only new property added in 5.1. UIPopoverController doesn't have anything new that I can see. – Jeremy Fuller Mar 08 '12 at 04:18
  • It's just plain weird that they would do this... Can you override the delegate method, or provide a custom button? – CodaFi Mar 08 '12 at 04:19
  • I may have to roll a custom solution like MGSplitViewController, but I'd really rather not... it was working perfectly. I find it hard to believe that this made it out of beta. – Jeremy Fuller Mar 08 '12 at 04:26
  • Just one more thought before this gets too long: Why not just set a custom UIBarButtonItem as the left item, then set your Splitview's popover method to nil, but then add a custom method as the new left button's target? That way, you have reference to the barbutton so you can just present the popover from it yourself, no Subclassing or re-rolls needed. – CodaFi Mar 08 '12 at 04:36

4 Answers4

5

This change seems poorly thought out. Sure guys, we break anything in the detail view that uses a swipe. Awesome!

To answer your 'bring back the black' question, if it's merely a question of the top navbar color, you could use the appearance proxy. For example:

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

The appearance proxy can be set very specifically if necessary; it has a containers model. There's a very good WWDC video on it.

With respect to just reverting to the old behavior with the new compiler, frankly, I'd love to know as well. The new behavior also breaks action sheets in the master view; previously, when the master view was presented in a popover, they'd do the right thing. Now, it's an assertion failure.

Allan Bazinet
  • 1,752
  • 15
  • 15
  • `setTintColor` may work as a last resort -- thanks for that. Unfortunately, the height of the popover (`contentSizeForViewInPopover`) is also pretty important for this app, and they seem to have completely broken that behavior. – Jeremy Fuller Mar 08 '12 at 05:01
  • Since reverting to the old behavior doesn't seem to be possible, I've resigned myself to fixing it up to look better. Your answer made that possible, so I'm marking it as the answer. – Jeremy Fuller Mar 08 '12 at 19:11
  • hi, by any chance did you come up with a way to restore the popover effect in iOS 5.1? – CocoaEv Aug 25 '12 at 18:52
0

It is possible to revert! - with MGSplitViewController. It gives you a similar API to the iOS control but with old popover and much more control.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
0

as of iOS 5.1

From the docs:

In iOS 5.1, the UISplitViewController class adopts the sliding presentation style when presenting the left view (previously seen only in Mail). This style is used when presentation is initiated either by the existing bar button item provided by the delegate methods or by a swipe gesture within the right view. No additional API adoption is required to obtain this behavior, and all existing APIs—including that of the UIPopoverController instance provided by the delegate—will continue to work as before.

small work around over here ->

theiOSDude
  • 1,480
  • 2
  • 21
  • 36
0

Ok I had the same issue, this may help, it removes the black background that reaches to the bottom of the screen....

call this after you display your popoup...

- (void)removeInnerShadow {
    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    for (UIView *windowSubView in window.subviews) {

            if ([NSStringFromClass([windowSubView class]) isEqualToString:@"UIDimmingView"]) {
            for (UIView *dimmingViewSubviews in windowSubView.subviews) {

                for (UIView *popoverSubview in dimmingViewSubviews.subviews) {

                    popoverSubview.layer.shadowOpacity=0;
                    popoverSubview.layer.masksToBounds = NO;

                     if([NSStringFromClass([popoverSubview class]) isEqualToString:@"_UIPopoverSlidingChromeView"])
                     {

                         popoverSubview.layer.shadowOpacity=0;
                         popoverSubview.layer.masksToBounds = NO;

                     }
                }
            }
        }
    }
}
Jeremy Fuller
  • 3,391
  • 1
  • 32
  • 27