IOS keyboard hiding

Source: Internet
Author: User
Method 1: Add [self. textfiled resignfirstresponder] to the button clicking event.

Method 2:

In the XIB file, you can not add a view control on the view page. A simple method is to set the class of the view page to uicontrol (this class inherits from uiview)

 

. H file:

# Import <uikit/uikit. h> @ interface homeviewcontroller: uiviewcontroller @ property (retain, nonatomic) iboutlet uitextfield * namefield; @ property (retain, nonatomic) iboutlet uitextfield * passwordfield;-(ibaction) textfielddoneediting) sender;-(ibaction) backgroundtap :( ID) sender; @ end

. M file:

 

 

# Import "homeviewcontroller. H" @ interface homeviewcontroller () @ end @ implementation homeviewcontroller

 

@ Synthesize namefield; @ synthesize passwordfield;-(ID) initwithnibname :( nsstring *) nibnameornil bundle :( nsbundle *) handle {self = [Super initwithnibname: nibnameornil Bundle: role] if (Self) {// custom initialization} return self;}-(void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view from Its nib .} -(void) viewdidunload {[self setnamefield: Nil]; [self setnamefield: Nil]; [self setpasswordfield: Nil]; [Super viewdidunload]; // release any retained subviews of the main view. // e.g. self. myoutlet = nil;}-(bool) returns :( uiinterfaceorientation) interfaceorientation {return (interfaceorientation = inline);}-(void) dealloc {[namefield release]; [namefield release]; [passwordfield release]; [Super dealloc];}-(ibaction) textfielddoneediting :( ID) sender {[Sender resignfirstresponder];}-(ibaction) backgroundtap :( ID) sender {[namefield resignfirstresponder]; [passwordfield resignfirstresponder];} @ end
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.