Mode 1. Use gestures and notifications to monitor the keyboard using the pop-up keyboard when double-clicking the input
The code is as follows:
1. Monitor keyboard notifications
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (ADDTAP) Name: Uikeyboarddidshownotification Object:nil];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (KEYDISMISS) Name: Uikeyboardwillhidenotification Object:nil];
2. Add a method to the pop-up keyboard
-(void) Addtap {
_tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (resign)];
[Self.view Addgesturerecognizer:_tap];//self.view can be changed depending on the situation
}
3. Gestures of events
#pragma mark-click Gesture Event method
-(void) resign {
[Self.view Endediting:yes];
}
4. How the keyboard disappears
-(void) Keydismiss {
[Self.view Removegesturerecognizer:_tap];
}
Method 2: Using the TextView proxy method
Proxy methods for #pragma mark-textview
-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) Text {
if ([text isequaltostring:@ "\ n"]) {
[TextView Resignfirstresponder];
return NO;
}
return YES;
}
In IOS Development, click Enter text as a child control, and then exit the text TextView