Older code, for reference only
The main functional points involved are:
1, Password input box to hide the input characters, in place of black dots, and sometimes set a button on the edge, let the user choose whether to need ciphertext input
2, login will check the input box, if the input is not legal, pop-up window prompt users
3. Reset will empty the input
4, when you click on the blank space, you can put up the input keyboard to prevent users from clicking Login
5, pop-up keyboard to fit the input box, to ensure that the input box is not blocked by the keyboard
1, for the text box to hide the input, we just need to set its Securetextentry property to True is OK:
Object-c Code
Self.password.securetextentry=true;
2, the login function will save the user input to the appdelegate, so that in the future when the need for the program can also be taken:
-(ibaction) Login: (ID) sender{
NSString *username = [Self.userName.text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset];
NSString *password = [Self.password.text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset];
Appdelegate *delegate = (appdelegate *) [[uiapplication sharedapplication] delegate];
if (username.length==0| | password.length==0) {
Uialertview *alert= [[Uialertview alloc] initwithtitle:@ "Input invalid" message:@ "UserName or Password is empty" delegate : nil cancelbuttontitle:@ "OK" otherbuttontitles:nil, nil];
[Alert show];
Return
}
[Delegate.userstate setobject:username forkey:@ "Kusername"];
[Delegate.userstate setobject:password forkey:@ "Kpassword"];
Appdelegate *appdelegate = [[UIApplication sharedapplication] delegate];
AppDelegate.window.rootViewController = Appdelegate.tabbar;
}
3. At reset, in addition to emptying the contents of the UI control, you also need to empty the contents of the Appdelegate:
-(ibaction) Reset: (ID) sender{
[Email protected] "";
[Email protected] "";
Appdelegate *delegate = (appdelegate *) [[uiapplication sharedapplication] delegate];
[Delegate.userstate setobject:@ "" forkey:@ "Kusername"];
[Delegate.userstate setobject:@ "" forkey:@ "Kpassword"];
}
All methods that are bound to the UI space require a return type ibaction
iOS Landing screen