Achieve functional effects:
(1) interface can enter QQ number and password, click the login background output QQ number and password
(2) Input box has a message, focus on the input box to indicate that the information disappears
(3) When you click the login button, the phone keyboard automatically hidesLearning
Effects: familiarity with control properties, events and code associations
As follows:
implementation process: 1. Drag the corresponding control to the interface, set the control properties
< Span class= "token p" style= "Color:rgb (90,90,90); font-family: ' Microsoft Yahei '; font-size:18px; line-height:29px; White-space:pre-wrap; Outline:none!important ">2. Drag line association variables and events. Obviously, to get the interface input QQ number and password, you have to set the input box variables. Click the button to trigger the event, the code to do the corresponding logical processing.
The following is the connection of the attribute (the solid only indicates the association):
button Event Wiring Association method:
3. Get QQ number and password, click to unlock login button background output QQ number and password
viewcontroller.m
viewcontroller.m//Simple QQ Login////Created by zxh on 15/8/19.//Copyright (c) 2015 <span style= "font-family: ' Mic Rosoft Yahei '; White-space:pre-wrap; " >zxh</span>. All rights reserved.//#import "ViewController.h" @interface Viewcontroller ()//qq number @property (weak, nonatomic) Iboutlet Uitextfield *num;//Password @property (weak, nonatomic) Iboutlet Uitextfield *pwd;//Login Method-(ibaction) login;@ End@implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Do any additional setup after loading the view, typically from a nib.} -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /** * Login */-(ibaction) Login {nsstring *qqnum = Self.num.text; NSString *pwd = Self.pwd.text; NSLog (@ "num=%@,pwd=%@", qqnum,pwd); Exit keyboard//Responder//First responder: The control that calls out the keyboard//Improper first responder (will put the keyboard back)//mode one//[self.num Resignfirstresponder]; [Self.pwd Resignfirstresponder]; Mode two view settings edit end [Self.view endediting:yes];//exit Keyboard} @end
Get everyone wondering: Why are attributes written in. m files instead of. h files? This is because the QQ number and password is not provided for outside use, we'd better not expose it. All written in. m files.
--Article to this!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS Basic UI (a) simple QQ login