从5.0更新到iOS 5.1后,从splitview控制器的弹出窗口中的按钮显示的操作表正在使应用程序崩溃。它输出的错误是: * 断言失败 - [UIActionSheet presentSheetInPopoverView:],/ SourceCache / UIKit / UIKit-1914.84 / UIActionSheet.m:1816 所以在Splitview控制器的主视图中,我有一个相机按钮,我试图提出一个动作表,要求从相机胶卷或相机中选择。有什么想法吗?
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);
};
答案 0 :(得分:3)
我遇到了同样的问题,并通过从主窗口显示它来修复它。试图从触摸按钮附近的任何其他视图或矩形显示它会导致同样的崩溃。以下是仅在纵向模式下显示在屏幕中间的代码:
if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation))
[sortSheet showInView:self.view.window];
else
[sortSheet showFromBarButtonItem:sender animated:YES]; // rightBarButton
已经报告了多个radar bugs。但请提交一份新的,以便他们知道每个人都在发生这种情况。
如果你不在视图控制器中使用:[UIApplication sharedApplication] .keyWindow来获取显示视图的主窗口。
答案 1 :(得分:1)
这是一个潜在的解决方法,它让我创建一个完全独立的弹出窗口并插入我的UIActionSheet,这可以方便地添加一个非常酷的滑入效果:
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);
};