来自UIAlertView的UIActionSheet

当用户触摸UIAlertView中的按钮时,我正在尝试显示UIActionSheet:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { UIActionSheet *actionSheet = ... [actionSheet showFromTabBar:self.tabBarController.tabBar]; } } 

当显示操作表时,警报视图仍然位于操作表后面的屏幕上,当我触摸操作表中的按钮时 – 操作表消失但整个屏幕变暗,警报视图仍然打开,我可以’解雇它。

我尝试了几件事,例如在短暂延迟后显示操作表或以编程方式解除警报视图,但没有任何效果。 在最好的情况下(以编程方式解除警报视图),警报视图在稍微奇怪的转换后确实消失了,但是当它执行时,我在日志中得到了“wait-fence未能收到回复”错误。

如何以有序的方式从警报视图中显示操作表?

在这种情况下,你应该使用

 - (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调用dismissWithClickedButtonIndex:animated:方法

 if (buttonIndex == 0) { [alertView dismissWithClickedButtonIndex:0 animated:YES]; UIActionSheet *actionSheet = ... [actionSheet showFromTabBar:self.tabBarController.tabBar]; }