iOS development from beginner to proficient--xib use, landing interface small trial sledgehammer

Source: Internet
Author: User
Tags uikit

Xib use, landing interface small test sledgehammer

Create a new view controller, see Click to view

Drag the desired control inside the created Vcroot.xib and drag it to the appropriate control to add the property and add the event to the login button.

Inside the VCRoot.h file:

#import <UIKit/UIKit.h>  @interface vcroot : uiviewcontroller //iboutlet represents the Xib created from the@property(Weak,nonatomic)IboutletUitextfield *mname;@property(Weak,nonatomic)IboutletUitextfield *mpassword;@property(Weak,nonatomic)Iboutlet UIButton*mlogin;//Above @property are set properties//The following is a function event- (ibaction) Presslogin: (ID) sender;@end

Inside the vcroot.m file:

#import "VCRoot.h"  @interface vcroot ()@end @implementation vcroot - (void) Viewdidload {[SuperViewdidload];additional setup after loading the view from its nib.}- (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}/ * #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using    [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */- (ibaction) Presslogin: (ID) Sender {NSString* Name = @"Jack";NSString* Pass = @"123456";//Determine if correct, and popup dialog prompt    if([_mname. TextIsequal:name] && [_mpassword. TextIsequal:pass]) {Uialertview * alert =[[uialertview alloc]initwithtitle:@"Hint"message:@"User name and password correct, login successful"DelegateNilcancelbuttontitle:@"OK"otherbuttontitles:@"Cancel",Nil];    [Alert show]; }Else{Uialertview * alert =[[uialertview alloc]initwithtitle:@"Hint"message:@"The user name and password are not correct, please re-enter"DelegateNilcancelbuttontitle:@"OK"otherbuttontitles:@"Cancel",Nil];    [Alert show]; }}//Click on the blank space to retract the keyboard-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{[_mname Resignfirstresponder]; [_mpassword Resignfirstresponder];}@end

iOS development from beginner to proficient--xib use, landing interface small trial sledgehammer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.