7

我有一个基于 UISplitViewController 的应用程序,它在拆分的 MasterViewController 中显示一个 ActionSheet。在 iOS 5.1 之前,我在拆分呈现的弹出窗口中显示操作表没有问题,但现在,显示 MasterController 的新“滑入”方式显然有问题。

问题是,当我尝试使用任何 [actionSheet show..] 方法呈现 ActionSheet 时,应用程序崩溃并出现以下错误(确切的断言如下)。

*** Assertion failure in -[UIActionSheet presentSheetInPopoverView:], /SourceCache/UIKit_Sim/UIKit-1914.84/UIActionSheet.m:1816
sharedlibrary apply-load-rules all
Error in re-setting breakpoint 1:
Catchpoint 2 (throw)Error in re-setting breakpoint 1:
Error in re-setting breakpoint 1:
Current language:  auto; currently objective-c

我用谷歌搜索了一段时间,但没有实质性的答案.. 有人说这可能是新的 SplitViewController 中的一个错误...

想法?

先感谢您!

更新:我发布了一个可能的通用解决方法,请查看。如果它对您有用,请发表评论....如果没问题,我会在几天内将其标记为正确

4

5 回答 5

4

基于以上内容,并且非常尊重在 WWDC 上帮助我的 Apple 工程师,这里的解决方案不仅可以解决这个错误,而且还可以将弹出框指向右侧按钮。

    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
    {
        [actionSheet showFromBarButtonItem:self.actionSheetBarButtonItem animated:YES];
    } 
    else 
    {
        CGRect windowsRect = [self.navigationController.toolbar convertRect:self.actionSheetBarButtonItem.customView.frame toView:self.view.window];

        [actionSheet showFromRect:windowsRect inView:self.view.window animated:YES];
    }
于 2012-06-13T22:13:45.237 回答
2

我也有同样的问题。

至少可以防止崩溃的一种解决方法是像这样显示您的 UIActionSheet:

if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
    [self.actionSheet showFromBarButtonItem:sender animated:YES];
} else {
    [self.actionSheet showInView:self.view.window];
}

所以在纵向模式下,操作表显示在窗口的中央。不理想,但至少它不会崩溃。在横向模式下,它的行为正常。

于 2012-03-19T06:59:20.117 回答
1

正如 omz 评论的那样,苹果在 iOS 5.1.1 中似乎已经解决了这个问题。所以我决定将它添加到我的应用程序更改日志的已知问题部分,解决方法是建议用户升级到 iOS 5.1.1。

于 2012-06-02T06:53:41.740 回答
0

保持指向特定选项的弹出框效果的另一个选项,您实际上可以执行以下操作: 1. 创建自己的 UIPopover 2. 在 UIPopover 内创建自己的 UIViewController。3. 在新创建的 UIViewController 中显示 UIActionSheet。4. 根据 UIActionSheet 的大小设置PopoverContentSize。5. 最后,连接 UIActionsheet 的 Clicked 方法以关闭弹出框。

需要更多的代码,但在大多数情况下为您提供与以前相同的功能,并且为 UIActionsheet 提供了一个很酷的小滑入效果。

于 2012-04-03T21:44:11.257 回答
0

我认为以下是基于 Tap Form 答案的通用解决方案:

CGRect windowsRect = [actionSheetContainerView convertRect:viewToPresentActionSheet.frame toView:actionSheetContainer.window];
[actionSheet showFromRect:windowsRect inView:actionSheetContainer.window animated:YES];

这将重新发送窗口中的 actionSheet,但指向正确的方向

于 2012-04-24T15:15:35.253 回答