Simplifying tuzzolotron's answer:
Where the following outlet is properly connected in your xib
IBOutlet UITextView *myTextView;
Use this in the view controller:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([myTextView isFirstResponder] && [touch view] != myTextView) {
[myTextView resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
A tap on the View Controller's View, outside of the Text View, will resign the first responder, closing the keyboard.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…