textview中有一个视图。固定在桌子的底部。我担心的是当键盘显示视图根据他的内容向上移动时。和键盘隐藏他们隐藏他们的内容。发生了一些问题。它向上移动,然后当我们开始写textview时,它们向下移动。请帮助,如果它没有解决我的公司解雇我,我请求你请帮助。这是我的代码。
- (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-keyBoadSize-newSize.height-25, self.view.frame.size.width, newSize.height+25);
}
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
keyBoadSize =kbSize.height;
CGRect keyboardRect = [aNotification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
[UIView animateWithDuration:0.2f animations:^{
if (text.text.length ==0 ]) {
bottomView.frame =CGRectMake(0, [[UIScreen mainScreen] bounds].size.height -kbSize.height-60, bottomView.frame.size.width, 60);
}
else
{
bottomView.frame =CGRectMake(0, [[UIScreen mainScreen] bounds].size.height -kbSize.height-bottomView.frame.size.height, bottomView.frame.size.width, 60);
}
[tableViews setContentInset:UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0)];
}];
}
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
keyBoardDownHeight =kbSize.height;
[UIView animateWithDuration:0.2f animations:^{
if (text.text.length ==0) {
bottomView.frame =CGRectMake(0,[[UIScreen mainScreen] bounds].size.height - 60 , bottomView.frame.size.width, bottomView.frame.size.height);
}
else
{
bottomView.frame =CGRectMake(0,[[UIScreen mainScreen] bounds].size.height -bottomView.frame.size.height-10 , bottomView.frame.size.width, bottomView.frame.size.height);
}
[tableViews setContentInset:UIEdgeInsetsZero];
}];
}