Change height of inputAccessoryView issue

后端 未结 6 1874
感情败类
感情败类 2020-12-24 03:19

When I change the height of inputAccessoryView in iOS 8, the inputAccessoryView not go to the right origin, but covers the keyboard.

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 03:49

    Try this: _vwForSendChat is the input accessory view _txtViewChatMessage is the textview inside input accessory view

    -(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);
    if (newFrame.size.height < 40) {
        _vwForSendChat.frame = CGRectMake(0, 0, self.view.frame.size.width, 40);
    } else {
        if (newFrame.size.height > 200) {
            _vwForSendChat.frame = CGRectMake(0, 0, self.view.frame.size.width, 200);
        } else {
           _vwForSendChat.frame = CGRectMake(0, 0, self.view.frame.size.width, newFrame.size.height);
        }
    }
    [self.txtViewChatMessage reloadInputViews];
    }
    

提交回复
热议问题