IOS 5.1 + UISplitViewController in PortraitMode + UIActionSheet in MasterController = Approval Error

I have a UISplitViewController based application that shows an ActionSheet in a MasterViewController Split. Prior to iOS 5.1, I had no problems presenting the action sheet in the popover presented by the section, but now, apparently, something is wrong with the new β€œslide” way to show MasterController.

The fact is that when I try to present an ActionSheet using any [actionSheet show ..] method, the application crashes with the following error (the exact statement 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 find this for a while, but no significant answers. Some people say this may be a bug in the new SplitViewController ...

Ideas?

Thank you in advance!

UPDATE: I posted a possible general workaround, check it out. If this works for you, leave a comment ... If everything is in order, I will mark it as correct in a couple of days

+7
source share
5 answers

Based on the foregoing, and with great respect to the Apple engineer who helped me at WWDC, here is a solution that not only works around this error, but also points to a popover on 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]; } 
+4
source

I have such a problem too.

One workaround that at least prevents a crash is to show your UIActionSheet as follows:

 if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { [self.actionSheet showFromBarButtonItem:sender animated:YES]; } else { [self.actionSheet showInView:self.view.window]; } 

Thus, in portrait mode, the action sheet is displayed in the center of the window. Not perfect, but at least it doesn't fall. And when in landscape mode, he behaves as usual.

+2
source

As omz commented, it looks like this problem was resolved in Apple's iOS 5.1.1. So I decided to just add it to a known part of the change log for my application, and a workaround is to offer users to switch to iOS 5.1.1.

+1
source

Another option that allows you to influence popover on a particular option, you can do the following: 1. Create your own UIPopover 2. Create your own UIViewController inside UIPopover. 3. Display the UIActionSheet inside the newly created UIViewController. 4. SetPopoverContentSize from the size of the UIActionSheet. 5. Finally, swipe your UIActionsheet Clicked method to reject the popover.

It gets a little more code, but gives you the same functionality as before, and has a cool slide effect for UIsheetheet.

0
source

I think the following general solution is based on Tap Form's answer:

 CGRect windowsRect = [actionSheetContainerView convertRect:viewToPresentActionSheet.frame toView:actionSheetContainer.window]; [actionSheet showFromRect:windowsRect inView:actionSheetContainer.window animated:YES]; 

This will lead to repeated action in the action window, but indicating the correct direction

0
source

All Articles