开发者

How to Hide keyBoard on return button itself in TextView in iPhone sdk?

In my iPhone App I am开发者_JAVA百科 using the control UItextView, I want to hide the keyBoard on "return" Button itself, I am not using any toolBar,NavigationBar and I don't want to import any other control like button on that View.

What shold I do to hide keyboard ?

Please Help and Suggest,

Thanks


You can use the shouldChangeTextInRange delegate and look for a line break:

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)string
{
    if([string isEqualToString:@"\n"]){
        [textView resignFirstResponder];
    }

    return YES;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜