开发者

How to hide keybord while typing in iphone app

I have 2 textview one is on top and other is at bottom. When I am trying to write something on bottom textview keyboard is coming on screen and I am not able to see what I am typing.

How to make keyboard invisible or placed on perfect place while typing b开发者_如何学JAVAelow textview?


- (void)textViewDidBeginEditing:(UITextView *)textView {
    if (textView == bottomTextView) {
        CGRect frame = self.view.frame;
        frame.origin.y -= 250;
        self.view.frame = frame;
    }
}

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView == bottomTextView) {
        CGRect frame = self.view.frame;
        frame.origin.y += 250;
        self.view.frame = frame;
    }
}

You can modify this 250 value.


The Answer to your problem lies here buddy..

Sliding UITextFeilds when keyboard appears

Its Best solution available.


Write This Delegate Methods For TextField

- (void)textFieldDidBeginEditing:(UITextField *)textField {

if (textField == txtUserName) {
    [txtUserName becomeFirstResponder];     
    [scrollView setContentOffset:CGPointMake(0,45) animated:YES];
} else if (textField == txtPassword) {
    [txtPassword becomeFirstResponder];     
    [scrollView setContentOffset:CGPointMake(0,105) animated:YES];
}
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
[scrollView setContentOffset:CGPointMake(0,0) animated:YES];
return YES;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜