Reputation: 6164
In my iPhone App when I click on UITextView keyboard becomes visible
I try to use resignFirstResponder on "textDidEndOnExit" event but the keyboard does not hide.
What should be done to hide the keyboard?
please Help and Suggest, Thanks.
Upvotes: 1
Views: 10388
Reputation: 1635
oneway, you can also hide keyboard when touch in view screen
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
if(touch.phase == UITouchPhaseBegan) {
[txtDetail resignFirstResponder];
}
}
Upvotes: 1
Reputation: 185
If you want your UITextView to not allow carriage returns, and close when the user presses the return key (or Done if you have changed the return key type) then implement the UITextViewDelegate protocol and use something like:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
return YES;
}
Upvotes: 1
Reputation: 2425
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
return NO;
}
return No; wont allow your keyboard to appear.Hope it helps.You will not require any toolbar or something.Give it a try...
Upvotes: 0
Reputation: 1921
Make a UIButton or UiBarButton and assign it a method in which write [textView resignFirstResponder];
Upvotes: 0
Reputation: 16553
I would suggest you to keep a toolbar and inside a button called "Dismiss" just above the keyboard. resign your responder and hide the toolbar when dismiss button is clicked. In the textView textViewShouldBeginEditing show the toolbar. Default hide the toolbar.
Upvotes: 1
Reputation: 134
Here another thread about this topic: how to hide the keyboard when empty area is touched on iphone
i think this can help you.
Upvotes: 2