I do it like this:

var alert = new UIAlertView();
alert.Title = "Test Alert";
alert.Message = "Test Alert Message";

alert.AddButton("OK");
alert.AddButton("Cancel");

alert.Clicked += (sender, e) => {
    var alertView = sender as UIAlertView;

    if (e.ButtonIndex == 0)
    {
        // OK button do something here
    }
    else if (e.ButtonIndex == 1)
    {
        // Cancel button do something else
    }
};

On Thu, May 31, 2012 at 10:25 AM, gordon pagan <[email protected]> wrote:
> Is it possible to send a message to a UIAlterview as if it were a manual
> button press? I learned this nice little trick of arresting program flow
> until the cancel button was clicked. This works very nicely. However, I have
> tried lots of other means to close this view but have been unsuccessful.
> Actually my real need for this is to show an alertview for several seconds
> then close it down after a fixed interval. I have tried timers and various
> other mechanisms but nothing seems to work for me. I have probably missed
> some very simple technique that the rest of the world knows about and I
> don't. I would be most grateful for advice that anyone can give on this
> topic. - Thanks.
>
>
>            string cancelButton = "Ok";
>            alert = new UIAlertView(caption, messageBoxText, null, 
> cancelButton,
> null);
>            alert.BackgroundColor = UIColor.FromWhiteAlpha(0f, 0.8f);
>            alert.Canceled += (sender, e) => {
>                buttonClicked = 0;
>                IsDisplayed = false;
>            };
>
>            alert.Show();
>
>            IsDisplayed = true;
>
>            while (IsDisplayed)
>            {
>                NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow
> (0.2));
>            }
>
>
>
>
>
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/Programmatically-induce-a-cancel-or-ok-for-a-UIAlertView-tp4655123.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch



-- 
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to