4

从 5.0 更新到 iOS 5.1 后,从 splitview 控制器的弹出窗口中的按钮呈现的操作表正在使应用程序崩溃。它输出的错误是:* Assertion failure in -[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);
                        };
4

2 回答 2

3

我遇到了同样的问题,并通过从主窗口显示它来修复它。尝试从触摸按钮附近的任何其他视图或矩形显示它会导致相同的崩溃。以下是仅在纵向模式下显示在屏幕中间的代码:

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

已经报告了几个雷达错误。但是请提交一份新的,以便他们知道每个人都在发生这种情况。

如果您不在视图控制器中,请使用:[UIApplication sharedApplication].keyWindow 获取主窗口以显示视图。

于 2012-03-21T14:52:44.220 回答
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);
                        };
于 2012-03-20T21:01:06.453 回答