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

查看:86
本文介绍了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没有<$ c $的完成按钮c> 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& feature = 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.

如何解决此问题?

推荐答案

这是在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.

这是目前唯一的解决方案,但请记住,这样做会导致您对scrollview的滚动位置进行额外的计算,因为当您对手动视图进行动画处理时,可以掩盖由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.

因此,您将需要滚动scrollview来调整文本字段的位置(要做的事情很多,最好不要介意延迟问题并保持快乐:))

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天全站免登陆