在iOS 8中更改inputAccessoryView的框架 [英] Changing the frame of an inputAccessoryView in iOS 8

查看:514
本文介绍了在iOS 8中更改inputAccessoryView的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长时间潜伏 - 第一次海报!

Long time lurker - first time poster!

我在使用 UITextView 像WhatsApp那样。

I am having an issue while recreating a bar with a UITextView like WhatsApp does it.

我使用自定义的 UIView 子类,并懒惰地实例化它:

I am using a custom UIView subclass, and lazily instantiating it on:


- (UIView *)inputAccessoryView

并返回YES:


- (BOOL)canBecomeFirstResponder

现在,我想更改 inputAccessoryView UITextView 的大小增加时。在iOS 7上,我只是改变所述视图框架的大小 - 而不是它的原点 - 然后调用 reloadInputViews 并且它将起作用:视图将被移动向上,以便在键盘上方完全可见。

Now, I want to change the size of the inputAccessoryView when the UITextView grows in size. On iOS 7, I would simply change the size of the frame of said view - and not it's origin -, and then call reloadInputViews and it would work: the view would be moved upwards so that it is fully visible above the keyboard.

但是,在iOS 8上,这不起作用。使其工作的唯一方法是将帧的原点更改为负值。这样会很好,除了它会产生一些奇怪的错误:例如, UIView 在输入任何文本时返回到原始框架。

On iOS 8, however, this does not work. The only way to make it work is to also change the origin of the frame to a negative value. This would be fine, except it creates some weird bugs: for example, the UIView returns to the 'original' frame when entering any text.

我有什么遗失的吗?我很确定WhatsApp使用 inputAccessoryView ,因为他们在拖动时解雇键盘的方式 - 仅在最新版本的应用程序中。

Is there something I am missing? I am pretty certain WhatsApp uses inputAccessoryView because of the way they dismiss the keyboard on drag - only in the latest version of the app.

如果你能帮助我,请告诉我!或者如果有任何测试你想让我跑!

Please let me know if you can help me out! Or if there is any test you would like me to run!

谢谢! :)

BTW,这是我用来更新自定义UIView高度的代码,名为 composeBar

BTW, here is the code I am using to update the height of the custom UIView called composeBar:

// ComposeBar frame size
CGRect frame = self.composeBar.frame;
frame.size.height += heightDifference;
frame.origin.y -= heightDifference;
self.composeBar.frame = frame;
[self.composeBar.textView reloadInputViews]; // Tried with this
[self reloadInputViews];                     // and this

编辑:完整源代码可用@ https://github.com/manuelmenzella/SocketChat-iOS

full source code is available @ https://github.com/manuelmenzella/SocketChat-iOS

推荐答案

我已经在这个问题上撞了我的头一段时间了,因为行为已经从iOS 7改为iOS 8.我尝试了一切,直到最明显的解决方案都适用于我:

I've been banging my head against the wall on this one for quite some time, as the behavior changed from iOS 7 to iOS 8. I tried everything, until the most obvious solution of all worked for me:

inputAccessoryView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

duh!

这篇关于在iOS 8中更改inputAccessoryView的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆