Bug 27188 - Crash when clicking UIActionSheet in iOS 8.1
Summary: Crash when clicking UIActionSheet in iOS 8.1
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-02-18 14:41 UTC by Yegor Ius
Modified: 2015-02-19 10:39 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

App crash in iOS 8 when clicking on UIActionSheet (4.51 KB, text/plain)
2015-02-18 14:41 UTC, Yegor Ius

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Yegor Ius 2015-02-18 14:41:35 UTC
Created attachment 9912 [details]
App crash in iOS 8 when clicking on UIActionSheet

Having an app crash when clicking on a button that displays a UIActionSheet.

Occurs only on iPad iOS 8.1, and only when in portrait mode. 

We have the button on the left side of the split screen. Clicking on the button (aka bringing up the UIActionSheet) causes the left side (the parent view of the UIActionSheet) to be dismissed. The app crashes because UIActionSheet no longer has a parent to point back to (since the left side view is dismissed). When in landscape mode, the left side is not dismissed, and thus no crash.

We understand that for iOS, it is recommended to use UIAlertController. But then we will need to use OS detection, to switch between UIActionSheet and UIAlertController.

Is there any way to fix this crash, i.e. not dismiss the parent view when clicking on UIActionSheet?

Crash log attached.

Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-02-19 03:32:20 UTC
The error message explains what you have to do:

Your application has presented a UIAlertController (<UIAlertController: 0x18bba5d0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

In any case this is not a bug in Xamarin.iOS, if you need further help please contact support using the support links listed in your Xamarin Account (https://store.xamarin.com/account/my/subscription).
Comment 2 Yegor Ius 2015-02-19 10:39:57 UTC
Alright, thank you.
We ended up wrapping both UIActionSheet (which works in iOS7 but is deprecated in iOS8) and UIAlertController (which works in iOS8 but not defined in iOS7) in another class, which performs OS detection via UIDevice.CurrentDevice.SystemVersion.