Bug 3913 - Creating a UIActionsheet on Master view of Splitview controller crashes App
Summary: Creating a UIActionsheet on Master view of Splitview controller crashes App
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-15 10:43 UTC by tchadwick
Modified: 2012-04-03 17:26 UTC (History)
4 users (show)

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


Attachments
Zipped project containing the offending issue (15.29 KB, application/x-zip-compressed)
2012-03-19 11:34 UTC, tchadwick
Details


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:
Status:
RESOLVED INVALID

Description tchadwick 2012-03-15 10:43:18 UTC
When I try to open a UIActionsheet (only)in portrait, on the Master View of a UISplitview, it crashes the app for iOS 5.1 users, 5.0 and older continue to work fine.  Also Landscape works as per usual.
if(lpm != null)  //lpm is short for long press menu
    lpm = null;
lpm = new UIActionSheet("Select an action to perform on " + Application.MO.CurrentList[indexPath.Row].Name);
foreach(var button in buttonList)
	lpm.AddButton(button);
lpm.CancelButtonIndex = buttonList.Count - 1;
lpm.Style = UIActionSheetStyle.BlackTranslucent;
lpm.ShowFrom(theList.RectForRowAtIndexPath(indexPath), this.View, true);
lpm.Clicked += delegate(object sender, UIButtonEventArgs e2) {
    lpm.DismissWithClickedButtonIndex(e2.ButtonIndex, false);
    Application.MO.RespondToLongPressSelection(e2.ButtonIndex);
							};
Comment 1 tchadwick 2012-03-15 10:44:39 UTC
Error:
* Assertion failure in -[UIActionSheet presentSheetInPopoverView:], /SourceCache/UIKit/UIKit-1914.84/UIActionSheet.m:1816
Comment 2 tchadwick 2012-03-15 11:00:54 UTC
Also Identified that it does not occur in the 5.1 simulator, only seems to happen on the actual device.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-03-15 19:09:36 UTC
I tried adding the code you showed in a new project, and it didn't crash on my iPad2. Can you attach your project so we can try that?
Comment 4 tchadwick 2012-03-16 11:10:27 UTC
I cannot attach the whole project, however when you are running this, are you running it on an iPad running iOS 5.1 and installing the test application after having updated?  I've found that it only affects those who have 5.1 installed and are installing the app for the first time.  It seems like when it is loaded onto a 5.1 iPad, apple is changing the behavior of the Rootview Controller so that in portrait, it is doing a slide-in animation versus the usual popover. Additional Details:  It is being presented from a UITableview that was pushed onto the Rootview controller.(don't know if that helps)  I am also getting the issue again when trying to present my actionsheet for picking a picture or taking one, when it is in portrait-mode and the camera button is in the bottom toolbar, when clicked, it runs this code:
public void ShowCameraOptions ()
{
	picker = new UIImagePickerController();
	picker.Delegate = new pickerDelegate();
			
	try
	{
		
            if(actionSheet != null)
	    {
		actionSheet.DismissWithClickedButtonIndex(2, false);	
		actionSheet = null;
	    }
			
	actionSheet = new UIActionSheet("Select an option to store an image in " + Application.MO.selectedParent.Name) {"Take a Photo", "Choose a Photo", "Cancel"};
	actionSheet.Style = UIActionSheetStyle.Default;
				
	actionSheet.ShowFrom(picButton, true);	
			
	actionSheet.Clicked += delegate(object sender2, UIButtonEventArgs e2) {
			
		switch(e2.ButtonIndex)
		{
		case 0:
		picker.SourceType = UIImagePickerControllerSourceType.Camera;
		camController = new UIPopoverController(picker);
                camController.PresentFromBarButtonItem(picButton, UIPopoverArrowDirection.Down, true);
				break;
		case 1:
		picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
				camController = new UIPopoverController(picker);
				camController.PresentFromBarButtonItem(picButton, UIPopoverArrowDirection.Down, true);
				break;
			case 2:
				break;
				}
					
			};
			} 
}
Comment 5 tchadwick 2012-03-16 11:40:36 UTC
If your still unable to see the issue, I can see about getting approval to attach the project. Or at least the Split-view controllers so you can see the full context.
Comment 6 tchadwick 2012-03-16 13:32:38 UTC
Also interesting is that the popover that displays the camera capture and the library, display without issue.
Comment 7 tchadwick 2012-03-16 14:21:20 UTC
Also, if I create a popovercontroller and add a UIViewcontroller to it, and insert the UIActionsheet, it works just fine.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2012-03-16 20:15:07 UTC
I'm unfortunately still able to see the issue.

Maybe you can create a simple test project that shows it, that way you don't have to attach your entire project here?
Comment 9 tchadwick 2012-03-19 11:34:33 UTC
Created attachment 1538 [details]
Zipped project containing the offending issue

I put together this very limited test-case that if you run on an iPad running iOS 5.1  and while in portrait, touch the Master button in the app, then the "Item" button, you will get an internal inconsistency error dealing with the popover content.
Comment 10 Sebastien Pouliot 2012-03-20 17:09:47 UTC
I can duplicate the issue using your solution. I think Rolf could not because he (likely) used a real UISplitViewController while it seems you're faking one using a UIViewController and exporting both:
splitViewController:willHideViewController:withBarButtonItem:forPopoverController: and
splitViewController:willShowViewController:invalidatingBarButtonItem:

That might be enough to fool the simulator but not quite enough for a real 5.1 device.
Comment 11 tchadwick 2012-03-20 17:14:28 UTC
I appreciate the information, now, the UISplitview was using the splitview provided by the xamarin/monotouch Master-Detail Application template, so does this need to be updated perhaps?