示例#1
0
    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();
    }
示例#2
0
 public void ButtonTitle()
 {
     string text = Guid.NewGuid().ToString("N");
     var alertView = new UIAlertView();
     alertView.AddButton(text);
     Assert.AreEqual(text, alertView.ButtonTitle(0));
 }
示例#3
0
 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();
 }
示例#4
0
 public void AddButton()
 {
     var alertView = new UIAlertView();
     alertView.AddButton("TEST");
     Assert.AreEqual(1, alertView.ButtonCount);
 }
示例#5
0
    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);
    }
示例#6
0
 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);
 }