简体   繁体   English

iOS8 - 具有动态高度的键盘输入附件视图

[英]iOS8 - keyboard input accessory view with dynamic height

We have a UITextView with a keyboard input accessory - the accessory is another UIView with a few buttons and another UITextView that grows in height as needed to display a message. 我们有一个带键盘输入附件的UITextView - 附件是另一个带有几个按钮的UIView和另一个根据需要增加高度以显示消息的UITextView。 (similar to what you see in iMessage) (类似于你在iMessage中看到的)

Everything works fine up through iOS7 and the input accessory grows upward above the keyboard when we update the frame size. 通过iOS7可以正常工作,当我们更新帧大小时,输入附件会在键盘上方向上增长。 But with iOS8, the accessory view grows downward extending over the predictive text and keyboard. 但是对于iOS8,附件视图在预测文本和键盘上向下扩展。

Is there a new way to tell the iOS8 keyboard view to relayout the accessory views? 有没有新方法告诉iOS8键盘视图重新布局附件视图? I've tried calling ReloadInputViews() and it doesn't seem to change anything. 我试过调用ReloadInputViews(),它似乎没有改变任何东西。

Stuck on this - thanks for the help. 坚持这个 - 谢谢你的帮助。

I override the addConstraint method on my view as apple sets a constraint with constant height for iOS8. 我在视图上覆盖了addConstraint方法,因为apple为iOS8设置了一个具有恒定高度的约束。 This seems to solve the issue. 这似乎解决了这个问题。

I meet this problem too. 我也遇到了这个问题。 What I do is override inputAccessoryView's layoutSubviews method and make the height is a fixed number. 我所做的是覆盖inputAccessoryView的layoutSubviews方法,并使高度是一个固定的数字。 like this: 像这样:

- (void)layoutSubviews {
    if (self.height > 38) {
        self.height = 38;
    }
}

PS: what strange is when your inputAccessoryView's height is above 50,inputAccessoryView will not grows downward. PS:当你的inputAccessoryView的高度超过50时,奇怪的是,inputAccessoryView不会向下增长。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM