iPad UIActionSheet 在modalView中的问题
我在 iPad 的 modalView 中使用 ActionSheet。 我从 navController 上的 UIBarButton 显示它。 第一个问题:如果我点击10次,它会显示10个actionSheet,这是一个问题。
第二个问题:在导航栏的右侧项目上,有一个“完成”按钮。 当我单击 actionSheet 按钮,操作表出现,然后单击“完成”按钮时,modalView 被关闭,操作表保持在屏幕上,然后应用程序崩溃。
显示操作表的代码:
UIActionSheet *iPadActionButton = [[UIActionSheet alloc] initWithTitle: @""
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: nil
otherButtonTitles: @"option 1", @"option 2", @"option ", nil];
iPadActionButton.destructiveButtonIndex = 2;
[iPadActionButton showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
[iPadActionButton setTag:200];
[iPadActionButton release];
关于如何解决这些问题有什么想法吗?
锐
I'm using an ActionSheet in a modalView, in iPad.
I'm showing it from a UIBarButton, on a navController.
First problem: if i click 10 times, it show's 10 actionSheet, which is a problem.
Second problem: on the right item of the navBar, there's a DONE button.
When i click on the actionSheet button, and the actionsheet appears, and I then click on the DONE button, the modalView is dismissed, and the actionsheet keeps on screen, and then the app crash.
Code to show the actionsheet:
UIActionSheet *iPadActionButton = [[UIActionSheet alloc] initWithTitle: @""
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: nil
otherButtonTitles: @"option 1", @"option 2", @"option ", nil];
iPadActionButton.destructiveButtonIndex = 2;
[iPadActionButton showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
[iPadActionButton setTag:200];
[iPadActionButton release];
Any ideas on how to resolve these issues?
Rui
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将对 UIActionSheet 的引用保留为类属性。
在你的标题中:
这将做两件事:
1)允许你检查它是否已经通过 [iPadActionButtonvisible] 属性可见。
2) 允许您在 viewWillDisappear:animated 中正确处理它:
I would keep a reference to the UIActionSheet as a class property.
In your header:
That will do two things:
1) Allow you to check to see if it's already visible with the [iPadActionButton visible] property.
2) Allow you to properly dispose of it in viewWillDisappear:anaimated: