Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 5.1 + UISplitViewController in PortraitMode + UIActionSheet in MasterController = Assertion failure

I have an app based on a UISplitViewController that shows an ActionSheet in the MasterViewController of the Split. Before iOS 5.1, I had no problems presenting the action sheet in the popover presented by the split, but now, apparently there is something wrong with the new "slide-in" way to show the MasterController.

The thing is that when I'm trying to present the ActionSheet, using any [actionSheet show..] method, the app crashes with the following error (The exact Assertion is the following).

*** Assertion failure in -[UIActionSheet presentSheetInPopoverView:], /SourceCache/UIKit_Sim/UIKit-1914.84/UIActionSheet.m:1816
sharedlibrary apply-load-rules all
Error in re-setting breakpoint 1:
Catchpoint 2 (throw)Error in re-setting breakpoint 1:
Error in re-setting breakpoint 1:
Current language:  auto; currently objective-c

I google this for a while, but no substantial answers.. some people say it can be a bug in the new SplitViewController...

Ideas?

Thank you in advance!

UPDATE: I posted a possible generic workaround, check it out. If it works for you, leave a comment.... If its ok, I will mark it as correct in a couple of days

like image 335
Omer Avatar asked Mar 15 '12 20:03

Omer


1 Answers

Based on the above, and with massive respect to the Apple engineer who helped me at WWDC, here is the solution which not only works around this bug, but also points the popover at the right button.

    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
    {
        [actionSheet showFromBarButtonItem:self.actionSheetBarButtonItem animated:YES];
    } 
    else 
    {
        CGRect windowsRect = [self.navigationController.toolbar convertRect:self.actionSheetBarButtonItem.customView.frame toView:self.view.window];

        [actionSheet showFromRect:windowsRect inView:self.view.window animated:YES];
    }
like image 166
Paul Whitby Avatar answered Sep 28 '22 04:09

Paul Whitby