【发布时间】:2013-06-25 19:46:05
【问题描述】:
我将UITextView 添加到UIToolBar。
当我完成我的UITextView 时,键盘被隐藏了,但文本也保留了我的视图。
当我开始我的UITextView时,照片链接:
当我完成我的UITextView,照片链接:
【问题讨论】:
标签: iphone ios objective-c keyboard uitextview
我将UITextView 添加到UIToolBar。
当我完成我的UITextView 时,键盘被隐藏了,但文本也保留了我的视图。
当我开始我的UITextView时,照片链接:
当我完成我的UITextView,照片链接:
【问题讨论】:
标签: iphone ios objective-c keyboard 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;
}];
}
【讨论】: