使用Xamarin.iOS在iOS 7上的ViewDidAppear方法中显示被阻止的UIAlertView不起作用 [英] Showing a blocked UIAlertView in ViewDidAppear Method on iOS 7 with Xamarin.iOS does not work

查看:127
本文介绍了使用Xamarin.iOS在iOS 7上的ViewDidAppear方法中显示被阻止的UIAlertView不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试在iOS 7上的ViewDidAppear方法中显示阻止的AlertView,我将无法解除AlertView。
没有触摸事件会到达AlertView。视图按钮将突出显示,但没有任何反应。
如果我在iOS上运行相同的代码< 7,它会正常工作。

if I try to show a blocked AlertView in the ViewDidAppear Method on iOS 7, I won´t be able to dismiss the AlertView. No touch events will reach the AlertView. The Button of the View will be highlighted, but nothing happen. If I run the same code on iOS < 7, it will work fine.

以下是示例代码:

    public override void ViewDidAppear(bool animated)
    {
        base.ViewDidAppear(animated);

        var alert = new UIAlertView("Title", "Message", null, "OK");
        alert.Dismissed += (sender, args) => result = true;
        alert.Show();

        while (!result)
            NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.1));
    }

我正在使用带有Apple SDK 6.1的Xamarin.iOS版本6.4.3.0。
我对Xamarin.iOS 6.9.6.0和Apple SDK 7.0的alpha有同样的问题。

I am using Xamarin.iOS Version 6.4.3.0 with Apple SDK 6.1. I have the same problems with alpha of Xamarin.iOS 6.9.6.0 and Apple SDK 7.0.

有人能告诉我这是什么问题吗?

Can somebody tell me what the problem is?

感谢您的帮助。

推荐答案

使用<$ c不是一个好主意$ c> NSRunLoop 阻止UI执行,但肯定有更好的方法。

It's not good idea to use NSRunLoop to block UI execution, but certainly there is a better way of doing it.

您可以使用async / await模式等待用户按 UIAlertView 按钮。以下是您可以使用的示例: https://gist.github.com/prashantvc/6725882

You can make use async/await pattern to wait for user to press the UIAlertView button. Here's the sample that you can use: https://gist.github.com/prashantvc/6725882

这篇关于使用Xamarin.iOS在iOS 7上的ViewDidAppear方法中显示被阻止的UIAlertView不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆