iOS UITextView 随键盘弹出界面上移

来源:互联网 发布:手机版word软件 编辑:程序博客网 时间:2024/06/10 08:23

- (void)textViewDidBeginEditing:(UITextView *)textView {

    CGRect frame = textView.frame;

    int offSet = frame.origin.y +70 - (self.view.frame.size.height -216.0); //iphone键盘高度为216.iped键盘高度为352

    [UIView beginAnimations:@"ResizeForKeyboard"context:nil];

    [UIView setAnimationDuration:0.5f];

    //将试图的Y坐标向上移动offset个单位,以使线面腾出开的地方用于软键盘的显示

    if (offSet > 0) {

        self.view.frame =CGRectMake(0.0f, -offSet,self.view.frame.size.width,self.view.frame.size.height);

        [UIView commitAnimations];

    }

}


- (void)textViewDidEndEditing:(UITextView *)textView {

    self.view.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height);

}

阅读全文
0 0
原创粉丝点击