Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'd be remiss if I didn't mention that enabling a login button only when the correct username and passwords are entered is probably not the best idea from a security standpoint. However, if that is what you want to do:</p> <p>// StudentLogInViewController.h</p> <pre><code>// Conform the UITextFieldDelegate @interface StudentLogInViewController &lt;UITextFieldDelegate&gt; @end </code></pre> <p>// StudentLogInViewController.m</p> <pre><code>#import "StudentLogInViewController.h" @interface StudentLogInViewController () @end @implementation StudentLogInViewController -(void)viewDidLoad { [super viewDidLoad]; UsernameText.delegate = self; PasswordText.delegate = self; } // This is a UITextFieldDelegate method - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { // The text field will not be updated to the newest text yet, but we know what the user just did so get it into a string NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; // Depending on which field the user is typing in, load in the appropriate inputs NSString *username, *password; if (textField == UsernameField) { username = newString; password = PasswordField.text; } else { username = UsernameField.text; password = newString; } // If both the username and password are correct then enable the button LoginButton.enabled = ([username isEqualToString:@"correctUsername"] &amp;&amp; [password isEqualToString:@"correctPassword"]); // Return YES so that the user's edits are used return YES; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload