我添加UITextView
到UIToolBar
. 当我完成我的UITextView
, 和键盘被隐藏,但文字也保留了我的看法。
当我开始我UITextView
的照片链接时:
当我完成我UITextView
的照片链接时:
我添加UITextView
到UIToolBar
. 当我完成我的UITextView
, 和键盘被隐藏,但文字也保留了我的看法。
当我开始我UITextView
的照片链接时:
当我完成我UITextView
的照片链接时:
当键盘可见时,您必须对视图进行动画处理。像 :
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
CGRect rect=self.view.frame;
rect.origin.y=rect.origin.y-100;
self.view.frame=rect;
[UIView commitAnimations];
您可以根据您的要求调整该 100 值。然后当钥匙消失时做相反的过程。
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame = textInputView.frame;
frame.origin.y -= kbSize.height;
textInputView.frame = frame;
frame = bubbleTable.frame;
frame.size.height -= kbSize.height;
bubbleTable.frame = frame;
}];
}
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame = textInputView.frame;
frame.origin.y += kbSize.height;
textInputView.frame = frame;
frame = bubbleTable.frame;
frame.size.height += kbSize.height;
bubbleTable.frame = frame;
}];
}