UIAsheet in Splitview, crashing with iOS 5.1 update

After upgrading to iOS 5.1 from 5.0, the action sheet presented using the button in the popover of the splitview controller breaks the application. Error of its output: * Confirmation error in - [UIActionSheet presentSheetInPopoverView:], / SourceCache / UIKit / UIKit-1914.84 / UIActionSheet.m: 1816 Thus, in the main view of the Splitview controller I have a camera button in which I try to present an action sheet asking for a choice from a camera roll or from a camera. Any ideas?

if(lpm != null) //Long Press Menu / Action Sheet 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); }; 
+4
source share
2 answers

This is potential work, it creates a completely separate popover and inserts my UIActionSheet into it, which conveniently adds a really cool slide effect:

 var buttonList = Application.MO.LoadLongPressOptions(false); if(lpm != null) lpm = null; if(longpresspopover != null) { longpresspopover.Dismiss(false); longpresspopover = null; } longpresspopovercontroller = new UIViewController(); longpresspopovercontroller.View.BackgroundColor = UIColor.Black; longpresspopover = new UIPopoverController(longpresspopovercontroller); longpresspopover.PresentFromRect(theList.Frame, this.View,UIPopoverArrowDirection.Any, true); lpm = new UIActionSheet("Select an action to perform:"); foreach(var button in buttonList) lpm.AddButton(button); lpm.CancelButtonIndex = buttonList.Count - 1; lpm.Style = UIActionSheetStyle.BlackTranslucent; lpm.ShowInView(longpresspopovercontroller.View); longpresspopover.SetPopoverContentSize(lpm.Frame.Size, false); lpm.Clicked += delegate(object sender, UIButtonEventArgs e2) { lpm.DismissWithClickedButtonIndex(e2.ButtonIndex, false); longpresspopover.Dismiss(true); Application.MO.RespondToLongPressSelection(e2.ButtonIndex); }; 
+1
source

I ran into the same problem and fixed it by showing it from the main window. Trying to show it from any other view or rectangle that is next to the pressed button causes the same crash. Below is the code that appears in the middle of the screen only in portrait mode:

  if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) [sortSheet showInView:self.view.window]; else [sortSheet showFromBarButtonItem:sender animated:YES]; // rightBarButton 

Several radar errors reported. But please write a new one so that they know that this is happening to everyone.

If you are not using the view manager, use: [UIApplication sharedApplication] .keyWindow to display the main window.

+3
source

Source: https://habr.com/ru/post/1401493/


All Articles