Appcelerator/Titanium 键盘工具栏与键盘错误不同步 [英] Appcelerator/ Titanium keyboard toolbar out of sync with keyboard bug

查看:24
本文介绍了Appcelerator/Titanium 键盘工具栏与键盘错误不同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

<TextField  id="txtPhone" top="20" left="15" right="40" returnKeyType="Ti.UI.RETURNKEY_GO" keyboardType="Ti.UI.KEYBOARD_TYPE_PHONE_PAD">
        <KeyboardToolbar platform="ios">
           <Toolbar>
              <Items>
                 <Button systemButton="Titanium.UI.iOS.SystemButton.FLEXIBLE_SPACE"/>
                 <Button title="Save" systemButton="Titanium.UI.iOS.SystemButton.SAVE"/>
              </Items>
           </Toolbar>
        </KeyboardToolbar>
</TextField>

我遇到的主要问题是 ios 没有 keyboardType="Ti.UI.KEYBOARD_TYPE_PHONE_PAD" 的完成"按钮.因此,我从其他 StackOverflow 答案中找到的解决方案与上述类似.

The orgional issue I had was that ios does not have a "Done" button for keyboardType="Ti.UI.KEYBOARD_TYPE_PHONE_PAD". Therefore the solution I found from other StackOverflow answers was similar to the above.

问题是键盘工具栏与键盘不同步.

The issue is that the keyboard toolbar does not appear in sync with the keyboard.

我找到了一个演示此问题的视频.https://www.youtube.com/watch?v=Cd95W1LvNXk&功能=youtu.be .不过看视频还是挺快的,建议0.25速度看.

I found a video that demonstrates this issue. https://www.youtube.com/watch?v=Cd95W1LvNXk&feature=youtu.be . However, it is quite fast on the video, so I suggest watching it at 0.25 speed.

如您所见,当关闭键盘时,数字键盘比键盘工具栏更快地到达屏幕底部.

As you can see, when closing the keyboard, the numberpad reaches the bottom of the screen faster than the keyboard toolbar.

同样,打开键盘时,键盘工具栏的显示速度比数字键盘快.

Similarly, when opening the keyboard, the keyboard toolbar appears faster than the number pad.

我该如何解决这个问题?

How can I fix this issue?

推荐答案

这是在 Titanium 中打开/关闭键盘工具栏的正常行为.

This is the normal behaviour of opening/closing keyboard toolbar in Titanium.

我认为工具栏的动画持续时间与键盘的持续时间相同,但不同之处在于曲线行为Ti.UI.ANIMATION_CURVE_EASE_OUT

I think the toolbar animates in same duration as the keyboard takes, but the difference is of curve behaviour which is Ti.UI.ANIMATION_CURVE_EASE_OUT

使用上述事实,如果您确实需要与键盘相同的时间,那么您可以创建一个手动视图并使用相同的曲线为其设置动画Ti.UI.ANIMATION_CURVE_EASE_OUT.

Using the above fact, if you really need the same timing as of keyboard, then you can create a manual view and animate it using the same curve Ti.UI.ANIMATION_CURVE_EASE_OUT.

这是目前唯一的解决方案,但请记住,这样做会导致您对滚动视图的滚动位置进行额外计算,因为当您为手动视图设置动画时,它会覆盖您向上移动的文本字段iOS 本身与键盘高度相同,在某些情况下,可能无法向上滚动最后一个文本字段.

This is the only solution for now, but remember that doing so can cause you to do extra calculations on scrollview's scroll positions because when you will animate a manual view, then it can cover up your text-fields which are moved up by iOS itself by same amount as of keyboard height, and in some cases it might not be possible to scroll up the last textfield.

因此,您需要滚动滚动视图来调整文本字段的位置(还有很多工作要做,最好不要介意延迟问题并保持快乐:))

So, you will need to scroll the scrollview to adjust the textfield position (it's a lot lot more task to do, better don't mind that delay issue and stay happy :) )

这篇关于Appcelerator/Titanium 键盘工具栏与键盘错误不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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