关于轮换的UIActionsheet

时间:2014-03-19 10:47:58

标签: ios uiactionsheet

我正在我的应用中启动 UIActionsheet 。在轮播中,操作表未集中对齐,因此在轮换时我会关闭操作表并使用

重新打开它
[actionsheet dismissWithClickedButtonIndex:-1 animated:NO];
[actionsheet showInView:self.view];

但问题出现在 iOS6 中会引发以下错误

*由于未捕获的异常终止应用' UIViewControllerHierarchyInconsistency',原因:'视图只能与at关联一次最多一个视图控制器!查看>与< _UIActionSheetHostingController:0x18615830>相关联。在将此视图与< _UIActionSheetHostingController:0xe0f28b0>相关联之前清除此关联。'

我尝试使用:

[actionsheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view];

但我仍然得到同样的错误。

iOS7 上,一切正常。

我搜索了很多,但修复主要是通过XIB完成的。我想以编程方式解决它。有没有人对此有任何想法?

1 个答案:

答案 0 :(得分:3)

编辑:此问题的原因是删除并且无法同时显示

[actionsheet dismissWithClickedButtonIndex:-1 animated:NO];
//adding some delay as dismissing one actionsheet and presenting actionsheet after some time
[self performSelector:@selector(showActionSheet) withObject:nil afterDelay:0.3];

添加以下方法:

-(void)showActionSheet
{
  [actionsheet showInView:self.view];
}