来自UIAlertView的UIActionSheet

Ami*_*ark 3 iphone xcode uialertview uiactionsheet ios

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

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

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

我尝试了几个方面,例如在短暂延迟后显示操作表或以编程方式解除警报视图,但没有任何效果.在最好的情况下(以编程方式解除警报视图)警报视图在一个有点奇怪的转换后确实消失但是我在日志中遇到了"等待栅栏未能收到回复"错误.

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

Rav*_*vin 16

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

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)

方法而不是,

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

所以你的代码将是:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        UIActionSheet *actionSheet = ...
        [actionSheet showFromTabBar:self.tabBarController.tabBar];
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢,