newbie question on UIalertView

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

newbie question on UIalertView

john_m0101
This post has NOT been accepted by the mailing list yet.
I've followed two examples of a simple Alert view and each one gives me an unhandled exception

example 1 from ShrinkRays.net is unchanged from what I copied and pasted and seems so simple it should be fireproof - what am I doing wrong
if the 'myAlertViewDlegate is nulled out the alert/message box shows fine so it's something to do with the delegate/handler
The same applies for another set of code I picked up from Ximianlists

as far as I can see it is giving an'invalid argument exception' -because something wrong has been sent to the button clicked method
I'm defeated on that one to know what to do about it
any help greatly appreciated

                this.myButton.TouchDown+= delegate {
                // UIAlertView al = new UIAlertView("warning","got here",new          //MyAlertViewDelegate(),"Cancel","OK");
                // al.Show();
                                ShowAlert();
                        };
               

void ShowAlert()
                {
                        UIAlertView alert = new UIAlertView();
                        alert.Title = "Are you sure?";
                        alert.AddButton("Ok");
                        alert.AddButton("Maybe");
                        alert.AddButton("No");
                        alert.Message = "This could explode the moon";
                        alert.Delegate = new MyAlertViewDelegate();
                        alert.Show();
                }
                public class MyAlertViewDelegate : UIAlertViewDelegate
                {
                        public override void Clicked (UIAlertView alertview, int buttonIndex)
                        {
                                int n =0;
                               
                        // Don't call base or you'll get:
                        // Unhandled Exception: //MonoTouch.Foundation.You_Should_Not_Call_base_In_This_Method
                        }
                        public override void Canceled (UIAlertView alertView)
                        {
                        // Don't call base or you'll get:
                        // Unhandled Exception: //MonoTouch.Foundation.You_Should_Not_Call_base_In_This_Method
                        }
                }