- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.Uitextfield*textfield=[[uitextfield Alloc]initwithframe:cgrectmake (Ten, -, $, $)]; Textfield.backgroundcolor=[Uicolor Redcolor]; [Self.view Addsubview:textfield]; }//the first method of collecting the keyboard-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{[Self.view endediting:yes];}//the second method of collecting the keyboard-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{[[UIApplication sharedapplication] sendaction: @selector (resignfirstresponder) To:nil from:nil Forevent:nil];} //the third way to pick up the keyboard-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{[[[ uiapplication sharedapplication] Keywindow] endediting:yes];}
Reference: iOS Development advanced-Tang Qi
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
ios-Development Tips-three ways to pick up the keyboard