I’ve got a bit of a doubt with UITextViews. I use to put UITextFields, and remove the keyboard by tapping outside with the faithful old:
-(void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event {
for (UIView* view in self.view.subviews) {
if ([view isKindOfClass:[UITextField class]])
[view resignFirstResponder];
}
}
I have this UITextView which is set on my view (and actually is self.myTV, to be precise), and I do the following
-(void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event {
for (UIView* view in self.view.subviews) {
if ([view isKindOfClass:[UITextView class]])
[view resignFirstResponder];
}
}
Same as above, save for the different class…
Well it doesn’t seem to work. Anyone has a suggestion?
The problem is that UITextView is not FirstResponder in your case as per the subview hierarchy of your app.
I would suggest you to categorize UIView to find the first responder as under:
This category on UIView, which calls on the UIWindow and traces for the first responder.