Problem:
A uitableview is added to a parent view and a Uitextview (Uitextview to the bottom and the rest for the UITableView layout). When you click Uitextview, the response is normal. When you finish writing, you need to call [Uitextview Resignfirstresponder] to hide the keyboard. This causes the keyboard to be closed.
Reason:
When the click UITableView, the trigger is not uitextview, that is, the touch is UITableView. When the finger touches, the response chain begins to respond from the top of the view. When it arrives at UITableView, UITableView is inherited uiscrollewview, so the signal is answered by UITableView, that is, the UITableView touch method is executed. Therefore, Uitextview is unable to respond.
Workaround:
Extend the UITableView to allow it to filter the first response:
@implementation UITableView (Uitouch)-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event {[[Self NEXTRESP Onder] Touchesbegan:touches withevent:event]; [Super Touchesended:touches withevent:event];} -(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event {[[Self nextresponder] touchesmoved:touches withevent : event]; [Super Touchesended:touches Withevent:event]; }-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event {[[Self nextresponder] touchesended:touches WithEven T:event]; [Super Touchesended:touches withevent:event];} @end
Where needed, import this.
Call in the class and determine if it is not the uitableview, if not, then you can put the keyboard away.
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event {[Super Touchesbegan:touches withevent:event]; UITableView *teableview = (UITableView *) [touches anyobject]; if (Teableview! = Self.tableview) {[TextView resignfirstresponder]; }}
===== ===== ===== ===== ===== ===== ===== ===== =====
There is also a method that is not recommended for use.
That is, when the keyboard bouncing up, put a clickable view on the top level, you can.
How IOS resolves unable to hide the keyboard