// Displays a UIAlertView and returns the index of the button pressed.
public static Task ShowAlert (string title, string message, params string [] buttons)
{
var tcs = new TaskCompletionSource ();
var alert = new UIAlertView {
Title = title,
Message = message
};
foreach (var button in buttons)
alert.AddButton (button);
alert.Clicked += (s, e) => tcs.TrySetResult (e.ButtonIndex);
alert.Show ();
return tcs.Task;
}
Then you do instead:
int button = await ShowAlert ("Foo", "Bar", "Ok", "Cancel", "Maybe");
Source : http://stackoverflow.com/questions/19120841/yes-no-confirmation-uialertview
No comments:
Post a Comment