Exemplo n.º 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();
    }
Exemplo n.º 2
0
 public void Message()
 {
     string text = Guid.NewGuid().ToString("N");
     var alertView = new UIAlertView();
     alertView.Message = text;
     Assert.AreEqual(text, alertView.Message);
 }
Exemplo n.º 3
0
    public void NewObject()
    {
        var obj = new UIAlertView();

        Assert.AreNotEqual(IntPtr.Zero, obj.ClassHandle);
        Assert.AreNotEqual(IntPtr.Zero, obj.Handle);
    }
Exemplo n.º 4
0
 public void ButtonTitle()
 {
     string text = Guid.NewGuid().ToString("N");
     var alertView = new UIAlertView();
     alertView.AddButton(text);
     Assert.AreEqual(text, alertView.ButtonTitle(0));
 }
Exemplo n.º 5
0
    public void AlertViewStyle()
    {
        var alertView = new UIAlertView();
        foreach (UIAlertViewStyle style in Enum.GetValues(typeof(UIAlertViewStyle)))
        {
            alertView.AlertViewStyle = style;

            Assert.AreEqual(style, alertView.AlertViewStyle);
        }
    }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
0
 public void CancelButtonIndex()
 {
     var alertView = new UIAlertView();
     Assert.AreEqual(-1, alertView.CancelButtonIndex);
 }
Exemplo n.º 8
0
 public void FirstOtherButtonIndex()
 {
     var alertView = new UIAlertView();
     Assert.AreEqual(-1, alertView.FirstOtherButtonIndex);
 }
Exemplo n.º 9
0
 public void IsVisible()
 {
     var alertView = new UIAlertView();
     Assert.IsFalse(alertView.Visible);
 }
Exemplo n.º 10
0
 public void AddButton()
 {
     var alertView = new UIAlertView();
     alertView.AddButton("TEST");
     Assert.AreEqual(1, alertView.ButtonCount);
 }
Exemplo n.º 11
0
 public void ObjectSame()
 {
     var a = new UIAlertView();
     var b = Runtime.GetNSObject<UIAlertView>(a.Handle);
     Assert.AreSame(a, b);
 }
Exemplo n.º 12
0
 public void NewObjectDispose()
 {
     var obj = new UIAlertView();
     obj.Dispose();
 }
Exemplo n.º 13
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);
    }
Exemplo n.º 14
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);
 }