Gooorack

Engineer1

  • Home
  • Projects
  • About

Example Login screen using a UIAlertView

Jul, 16, 2013Posted in Xamarin

UIAlertView has some different styles that can be applied to it.  The UIAlertViewStyleLoginAndPasswordInput creates a simple login popup.

UIAlertView alert = new UIAlertView ();
alert.Title = "Login";
alert.AddButton ("Login");
alert.AddButton ("Cancel");
alert.Message = "Please enter your login details";
alert.AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput;
alert.Clicked += ButtonClicked; 
alert.Show ();

Login

LoginWithInput

And the clicked event handler

public void ButtonClicked(object sender, UIButtonEventArgs e)
{
    UIAlertView parent_alert = (UIAlertView)sender;

    if (e.ButtonIndex == 0) 
    {
        // OK button
        UIAlertView alert = new UIAlertView ();
        alert.Title = "Login";
        alert.AddButton ("DONE");
        alert.Message = "Login: " + parent_alert.GetTextField(0).Text 
        + "\n" + "Password: " + parent_alert.GetTextField(1).Text;
        alert.Show ();
    }
    else{

        // Cancel button
        UIAlertView alert = new UIAlertView ();
        alert.Title = "Login";
        alert.AddButton ("DONE");
        alert.Message = "Cancel Clicked";
        alert.Show ();
    }

}

 

LoggedIn

Share: Twitter Facebook Google+
  • HowTo,
  • iOS,
  • Login,
  • MonoTouch,
  • UIAlertView,
  • Xamarin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • November 2017
  • September 2017
  • August 2017
  • July 2017
  • February 2014
  • August 2013
  • July 2013
  • June 2013

Categories

  • AI
  • C#
  • Jupyter
  • Programming
  • Uncategorized
  • Xamarin
  • Projects
  • About