- (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);
}