【发布时间】:2015-10-06 10:39:32
【问题描述】:
我有一张桌子,在这张桌子下面是 bottomView 。我的目标是在键盘向上时向上移动底部视图。但是当我们调整键盘时,这种方法会向上调用我的底部视图。我被卡住了
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
keyBoadSize =kbSize.height;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame=bottomView.frame;
keyBoardHeight = keyBoadSize;
frame.origin.y -=keyBoadSize;
bottomView.frame=frame;
frame = tableViews.frame;
frame.size.height -= keyBoardHeight;
tableViews.frame = frame;
}
我也在用
- (void)textViewDidChange:(UITextView *)textView
{
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
CGRect frame1 = [UIScreen mainScreen].bounds;
bottomView.frame=CGRectMake(0, frame1.size.height-keyBoardHeight-20-newSize.height, self.view.frame.size.width, newSize.height+50);
}
【问题讨论】:
-
@ElCaptain 我没有使用约束
-
你需要正确设置你的tableview的
contentInset。将其高度组件设置为键盘的高度。 -
@Abhinav 请帮忙
标签: objective-c iphone ios8