UIAlertView 中的 UIActionSheet

发布于 2024-12-18 15:38:07 字数 544 浏览 1 评论 0 原文

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

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

当显示操作表时,警报视图仍在操作表后面的屏幕上,当我触摸操作表中的按钮时 - 操作工作表消失,但整个屏幕变暗,警报视图仍然打开,我无法关闭它。

我尝试了几件事,例如在短暂延迟后显示操作表或以编程方式关闭警报视图,但没有任何效果。在最好的情况下(以编程方式关闭警报视图),警报视图在经过有点奇怪的转换后确实消失了,但当它消失时,我在日志中收到了“等待栅栏无法接收回复”错误。

如何从警报视图中有序地显示操作表?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑梦风尘 2024-12-25 15:38:07

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

- (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];
    }
}

谢谢,

In this case, you should use

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

method rather than,

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

so your code wil be:

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

Thanks,

终陌 2024-12-25 15:38:07

只需调用 dismissWithClickedButtonIndex:animated: 方法

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

Just call dismissWithClickedButtonIndex:animated: method for UIAlertView

if (buttonIndex == 0)
{
    [alertView dismissWithClickedButtonIndex:0 animated:YES];
    UIActionSheet *actionSheet = ...
    [actionSheet showFromTabBar:self.tabBarController.tabBar];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文