Compiling against 5.1 SDK forces new UIPopoverCont

2019-02-04 08:44发布

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

4条回答
三岁会撩人
2楼-- · 2019-02-04 09:21

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;

                     }
                }
            }
        }
    }
}
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-04 09:22

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.

查看更多
唯我独甜
4楼-- · 2019-02-04 09:33

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 ->

查看更多
\"骚年 ilove
5楼-- · 2019-02-04 09:33

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.

查看更多
登录 后发表回答