public void UIAlertViewExample() { if (Application.platform != RuntimePlatform.IPhonePlayer) { Debug.Log("Only supported on iOS!"); return; } var alertView = new UIAlertView(); alertView.AddButton("Option 1"); alertView.AddButton("Option 2"); alertView.Title = "Title"; alertView.Message = "This is the UIAlertView message"; alertView.Clicked += (sender, e) => { int option = e.Index + 1; Debug.Log(string.Format ("Option {0} clicked!", option)); }; alertView.Dismissed += (sender, e) => { Debug.Log("Dismissed"); }; alertView.Show(); }
public void Unsubscribe() { int count = 0; EventHandler callback = (sender, e) => { count++; }; var alertView = new UIAlertView(); alertView.Message = "Click OK"; alertView.AddButton("OK"); alertView.WillPresent += callback; alertView.WillPresent += callback; alertView.WillPresent -= callback; alertView.Show(); alertView.Dismiss(-1, false); System.Threading.Thread.Sleep(500); Assert.AreEqual(1, count); }
public void Show() { var alertView = new UIAlertView(); alertView.Message = "This is a test, n00bs!"; alertView.AddButton("OK"); alertView.AddButton("Cancel"); alertView.Dismissed += (sender, e) => { Console.WriteLine("Dismissed: " + e.Index); }; alertView.Clicked += (sender, e) => { Console.WriteLine("Clicked: " + e.Index); }; alertView.Canceled += (sender, e) => { Console.WriteLine("Canceled!"); }; alertView.Presented += (sender, e) => { Console.WriteLine("Presented!"); }; alertView.WillDismiss += (sender, e) => { Console.WriteLine("WillDismiss: " + e.Index); }; alertView.WillPresent += (sender, e) => { Console.WriteLine("WillPresent!"); }; alertView.Show(); }
public void Dismiss() { var alertView = new UIAlertView(); alertView.Message = "This is a test, n00bs!"; alertView.AddButton("OK"); alertView.AddButton("Cancel"); alertView.Show(); alertView.Dismiss(0, false); }