【问题标题】:Titanium MobileWeb App - Flashing BackgroundsTitanium MobileWeb 应用程序 - 闪烁的背景
【发布时间】:2013-09-04 09:31:48
【问题描述】:

遇到了一个很奇怪的问题,

在我的主窗口中,我有一个 backgroundImage

但是,每当我点击屏幕上的任意位置,或者尝试在文本字段中聚焦时,它都会闪烁

我添加了一个视频来展示它的行为

http://www.youtube.com/watch?v=W01vUQ_9DjY

窗口上唯一的样式是这样的:

"#main": {
    backgroundColor:"#f4b7d1",
    backgroundImage: "/images/bg.png"
}

我也试过

"#main": {
    backgroundColor:"#f4b7d1",
    backgroundImage: "/images/bg.png",
    backgroundFocusedImage: "/images/bg.png",
    backgroundSelectedImage: "/images/bg.png"
}

任何帮助将不胜感激,谢谢

【问题讨论】:

    标签: web-applications titanium background-image titanium-alloy


    【解决方案1】:

    我也遇到过这个问题。

    根本原因是 Titanium 在每次点击事件后都会重新分配 backgroundImage 属性,而不管实际属性是否已更改。

    要解决此问题,您可以破解处理 backgroundImage 更新的 Element.js 文件。

    可以在以下两个位置之一应用编辑(仅在 Windows 上测试,版本 3.1.3.GA):

    1. %ProjectFolder%\build\mobileweb\titanium\Ti\_\UI\Element.js

      这里我们正在编辑生成的 JS 文件,这必须在每次构建后完成。如果您不想编辑实际的 Titanium SDK 并且只想在最终构建中进行修复,此选项可能很有用。

    2. C:\%USER FOLDER%\App Data\Roaming\Titanium\mobilesdk\win32\3.1.3.GA\mobileweb\titanium\Ti\_\UI\Element.js

      如果您编辑此文件,您实际上是在更改 Titanium SDK。当您升级到新的 SDK 版本时,您只需重复此编辑。

    选择您的文件,然后从第 534 行开始应用此编辑:

    变化:

    bi = style.url(bi);
    nodeStyle.backgroundImage.replace(/'|"/g, '').toLowerCase() !== bi.toLowerCase() &&(nodeStyle.backgroundImage = bi);
    

    收件人:

    bi = style.url(bi);
    var currentB = nodeStyle.backgroundImage;
    var ind=currentB.lastIndexOf("/");
    var ind2= bi.lastIndexOf("/");
    if(nodeStyle.backgroundImage.substr(ind) !== bi.substr(ind2))
    {
           nodeStyle.backgroundImage.replace(/'|"/g, '').toLowerCase() !== bi.toLowerCase() && (nodeStyle.backgroundImage = bi);
    }
    

    此修复导致 Titanium 仅在背景图像的文件名更改时重置 backgroundImage 属性。请注意,此代码仅检查文件名是否更改,而不是路径,因此如果这对您很重要,请相应地调整您的代码。

    此修改也适用于 SDK 版本:3.2.0 GA。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 2020-08-17
      • 2014-03-19
      相关资源
      最近更新 更多