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.
Here is the example code:
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));
}
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?
Thanks for help.
It's not good idea to use NSRunLoop
to block UI execution, but certainly there is a better way of doing it.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With