问题描述
我试图在用户触摸 UIAlertView 中的按钮时显示 UIActionSheet:
I'm trying to show a UIActionSheet when the user touches a button in a UIAlertView:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIActionSheet *actionSheet = ...
[actionSheet showFromTabBar:self.tabBarController.tabBar];
}
}
当操作表显示时,警报视图仍在操作表后面的屏幕上,当我触摸操作表中的按钮时 - 操作表消失但整个屏幕变暗,警报视图仍然打开,并且我无法拒绝它.
When the action sheet is shown the alert view is still on the screen behind the action sheet, and when I touch a button in the action sheet - the action sheet disappears but the whole screen is dimmed with the alert view still on and I can't dismiss it.
我尝试了几种方法,例如在短暂延迟后显示操作表或以编程方式关闭警报视图,但没有任何效果.在最好的情况下(以编程方式关闭警报视图),警报视图确实在发生某种奇怪的转换后消失了,但我在日志中收到了等待栅栏未能收到回复"错误.
I tried several things, such as showing the action sheet after a short delay or dismissing the alert view programmatically, but nothing worked. In the best case (dismissing the alert view programmatically) the alert view did disappear after a somewhat-strange transition but I got a "wait-fence failed to receive reply" error in the log when it did.
如何从警报视图以有序的方式显示操作表?
How can I show an action sheet from an alert view in an orderly manner?
推荐答案
在这种情况下,你应该使用
In this case, you should use
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
方法而不是,
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
所以你的代码将是:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIActionSheet *actionSheet = ...
[actionSheet showFromTabBar:self.tabBarController.tabBar];
}
}
谢谢,
这篇关于UIAlertView 中的 UIActionSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!