简体   繁体   English

在iOS 7中对UITextView的输入视图和输入附件视图进行动画处理

[英]Animate input view & input accessory view of UITextView in iOS 7

UITextView's inputView and inputAccessoryView are very cool! UITextView的inputViewinputAccessoryView非常酷!

Right now I'm using the inputView to replace the keyboard when the user requests it. 现在,当用户请求时,我正在使用inputView替换键盘。 The docs say that after changing the inputView or the inputAccessoryView we have to call -reloadInputViews which, acording to the docs, does not animate the change: 文档说,在更改inputViewinputAccessoryView我们必须调用-reloadInputViews ,根据文档,它不会使更改具有动画效果:

You can use this method to refresh the custom input view or input accessory view associated with the current object when it is the first responder. 当它是第一响应者时,可以使用此方法刷新与当前对象关联的自定义输入视图或输入附件视图。 The views are replaced immediately—that is, without animating them into place . 这些视图将立即替换-即不将其设置为动画 If the current object is not the first responder, this method has no effect. 如果当前对象不是第一响应者,则此方法无效。

This means whenever the user presses the button to toggle the inputView , the keyboard disappears and the inputView appears and all happens instantly, which looks very un-iOS7-y due to the lack of a nice animation. 这意味着每当用户按下按钮来切换inputView ,键盘就会消失,并且inputView会立即发生,并且一切都会立即发生,由于缺少漂亮的动画,这看起来与iOS7-y非常不一样。

So, my question is: is it possible to animate the inputView into place when toggling it (without resorting to App Store-prohibitive actions)?. 因此,我的问题是:是否可以在切换inputView时使其动画到位(无需诉诸App Store禁止动作)?

You could do this by having your custom controls be in a sub view - then have the main view animate the sub view in. 您可以通过将自定义控件置于子视图中来实现此目的,然后在主视图中为子视图设置动画。

I suspect the api limitation is there so that Apple don't have to try making a one-size-fits-all animation. 我怀疑这里有api限制,因此Apple不必尝试制作一种适合所有人的动画。

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

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