storyboard xml manual segue

LarrySeymourLarrySeymour USMember ✭✭

i an usimng an older version of xcode due to an old macbook, so my version on xamarin does not create segue coorrectly in the storyboard xml. can someone copy me the xml of a storyboard with a manual segue.

i currently have a segue attached to a button and a shouldperformsegue method. when the button is pushed i check to see if a user/password combo is correct using a php method. if correct i set a boolean to true and run a performsegue method. my user i checked is brought back with php and a user object is created. this object is then used in my shouldperform but it always shows null, due to the segue being attached to the button, so i need a true manual segue. but as i mentioned my version doesnt create the xml so i need to know how to format the code so i can create the storyboard segue then enter the code p[roperly.
thanks.

Posts

  • LarrySeymourLarrySeymour USMember ✭✭

    here is my code

        private WebClient _client;
        private bool _successLogin = false;
        BusinessUser _bu = new BusinessUser();
        BusinessAuthorization _ba = new BusinessAuthorization();
        BusinessCode _bc = new BusinessCode();
    
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
    
            NetworkStatus internetStatus = Reachability.Reachability.InternetConnectionStatus();
            if (!Reachability.Reachability.IsHostReachable("google.com"))
            {
                UIAlertView alert = new UIAlertView("Conection", "No data connection available, please try agian later.", null, "Ok", null);
                btnSignin.Enabled = false;
                btnSignUp.Enabled = false;
                alert.Show();
            }
            else
            {
                btnSignin.Enabled = true;
                btnSignUp.Enabled = true;
    
                if ((NSUserDefaults.StandardUserDefaults.StringForKey("email") != null) && NSUserDefaults.StandardUserDefaults.StringForKey("email") !="")
                {
                    var email = NSUserDefaults.StandardUserDefaults.StringForKey("email");
                    LogininToCalendar();
                    //PerformSegue("SigninToCalendar", this);
                }
                else
                {
                    NSUserDefaults.StandardUserDefaults.SetString("","email");
                    NSUserDefaults.StandardUserDefaults.SetString("","password");
                }
            }
    
            btnSignin.TouchUpInside += (s, e) =>
            {
                LogininToCalendar();
            };
        }
    
        public override bool ShouldPerformSegue(string segueIdentifier, NSObject sender)
        {
            if (segueIdentifier == "SigninToCalendar" && _successLogin)
            {
                var controller = this.Storyboard.InstantiateViewController("CalendarViewController") as CalendarViewController;
                controller.User = _bu;
                return true;
            }
            else if (segueIdentifier == "SigninToSignup")
            {
                return true;
            }
            else
            {
                return false;
            }
            return base.ShouldPerformSegue(segueIdentifier, sender);
        }
    
        private void LogininToCalendar()
        {
            string email = "";
            string password = "";
    
            if (NSUserDefaults.StandardUserDefaults.StringForKey("email") != null && NSUserDefaults.StandardUserDefaults.StringForKey("email") != "")
            {
                email = NSUserDefaults.StandardUserDefaults.StringForKey("email");
                password = NSUserDefaults.StandardUserDefaults.StringForKey("password");
            }
            else
            {
                email = txtEmail.Text;
                password = txtPassword.Text;
            }
            _client = new WebClient();
            Uri uri = new Uri("http://biteboard.ca/php/signin.php");
    
            NameValueCollection parameters = new NameValueCollection();
    
            parameters.Add("email", email);
            parameters.Add("password", password);
    
            _client.UploadValuesCompleted += Client_UploadValuesCompleted;
            _client.UploadValuesAsync(uri, parameters);
    
        }
        private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            string json = Encoding.UTF8.GetString(e.Result);
            if (json.Contains(","))
            {
                if (swhRemember.On)
                {
                    NSUserDefaults.StandardUserDefaults.SetString(txtEmail.Text, "email");
                    NSUserDefaults.StandardUserDefaults.SetString(txtPassword.Text, "password");
                }
    
                JObject user = JObject.Parse(json);
    
                _bu.Id = (int)user["Id"];
                _bu.FirstName = (string)user["FirstName"];
                _bu.LastName = (string)user["LastName"];
                _bu.DiabetesInt = (int)user["DiabetesInt"];
                _bu.BloodPressureInt = (int)user["BloodPressureInt"];
                _bu.CholesterolInt = (int)user["CholesterolInt"];
                _bu.FitnessInt = (int)user["FitnessInt"];
                _bu.CodeId = (int)user["CodeId"];
                _bu.AuthId = (int)user["AuthId"];
                _ba.Id = (int)user["AuthId"]; ;
                _ba.Email = (string)user["Email"];
                _ba.Password = (string)user["Password"];
                _bc.Id = (int)user["CodeId"];
                _bc.CodeStr = (string)user["Code"];
                _bu.Code = _bc;
                _bu.Authorization = _ba;
    
                //var controller = this.Storyboard.InstantiateViewController("CalendarViewController") as CalendarViewController;
                //controller.User = _bu;
    
                _successLogin = true;
                PerformSegue("SigninToCalendar", this);
            }
            else
            {
                UIAlertView alert = new UIAlertView("Login", "This email and pssword combination do not exist, please try again.", null, "Ok", null);
                alert.Show();
            }
        }
    
  • LarrySeymourLarrySeymour USMember ✭✭

    i figured out a way to access my php code without using _client.UploadValuesCompleted += Client_UploadValuesCompleted; _client.UploadValuesAsync(uri, parameters);

    Instead I use
    using (WebClient client = new WebClient())
    {
    string json = client.DownloadString(new Uri("http:///phpFileName.php?parm1=" + value1.Text + "&param2=" + value2.Text));

            //remaining code goes here
        }
    
Sign In or Register to comment.