iPad/iPhone with Titanium 的启动视图

发布于 2024-11-19 04:26:57 字数 988 浏览 4 评论 0原文

我正在使用 Titanium 构建一个应用程序,在启动时加载一个大的远程 xml 文件。它显示通常的 Default.png 初始屏幕,然后到达窗口,显示正在加载。但我想做的是让闪屏一直持续到 xml 完全加载为止。

现在我的方法非常简单,我在开始时创建一个 imageView,使用 Default.png 作为图像,如下所示:

var startupView =Titanium.UI.createImageView({
image: 'iphone/Default-Portrait.png',
opacity:1,
zIndex:2
});

一旦触发 xhr.onload 函数(意味着 xml 文件已完全加载),我就会淡出这个启动视图通过这样做:

var startupAnimation = Titanium.UI.createAnimation({
curve:Ti.UI.ANIMATION_CURVE_EASE_OUT,
opacity:0,
delay: 0,
duration:300
});
startupView.animate(startupAnimation);

这工作得很好,但我遇到的问题是,不同的平台有不同的启动屏幕尺寸。到目前为止,我正在创建的应用程序在两个平台上都运行良好。在 ipad 上,屏幕显然更大,在 iphone 4 上,与 iphone 3gs 等相比,视网膜显示屏也更大。因此,我需要想出一些东西来使此代码在任何地方都能正常工作。

我尝试检查 if (Titanium.Platform.osname == "iphone") { 并将 iphone 的较小尺寸启动屏幕加载到 imageview 中,但不知怎的,它与“真实的”不一样“位于其下方的启动屏幕。因此,用户会看到初始启动屏幕和伪造的启动屏幕正在发生变化。看起来钛加载的默认启动画面与Default.png不一样,但它是Default-Portrait.png(应该只用于ipad)

我不知道这一切是否清楚,以及是否有人这里可以和我一起思考,但任何想法将不胜感激。

I am building an app with Titanium, where I load a big remote xml file on startup. It shows the usual Default.png splash screen, and then gets to the window, where it says that it's loading. But what I want to do, is to make the splash screen stick until the xml is fully loaded.

Now my approach for this is quite simple, I create an imageView at the start, with the Default.png as the image like so:

var startupView =Titanium.UI.createImageView({
image: 'iphone/Default-Portrait.png',
opacity:1,
zIndex:2
});

and once the xhr.onload function is triggered (meaning the xml file is fully loaded), I fade out this startup view by doing:

var startupAnimation = Titanium.UI.createAnimation({
curve:Ti.UI.ANIMATION_CURVE_EASE_OUT,
opacity:0,
delay: 0,
duration:300
});
startupView.animate(startupAnimation);

This works fine and all, but the problem I have is, that there are different splash screen sizes for different platforms. And so far the app I am creating works well on both platforms. On the ipad the screen is obviously bigger, on the iphone 4, the retina display is also bigger compared to iphone 3gs etc. Therefor I need to come up with something to make this code work nice everywhere.

I tried to check with if (Titanium.Platform.osname == "iphone") { and load the smaller size splash screen for the iphone into the imageview, but somehow it's not the same as the "real" splash screen underneath it. Because of this, the user sees that the initial splash screen and the faked splash screen is shifting. It seems like the default splash screen loaded by titanium is not the same as Default.png, but it's the Default-Portrait.png (which should only be used for the ipad)

I have no idea whether this all is clear, and whether someone here can think with me, but any ideas would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨的味道风的声音 2024-11-26 04:26:57

我用 Titanium iPad 应用程序做了同样的事情。我发现我需要创建自己的“启动屏幕”图像,而不需要状态栏所在的顶部 20 像素。由于钛应用程序可以全屏启动,因此 Default-Portrait.png 假定它可以是全屏。当您在非全屏应用程序中添加 Default-Portrait.png 视图时,它会将其向下移动 20px,并且您会为用户带来“移动”效果。

由于您在 iPhone 和 iPad 上运行,因此您可能需要为 iPad 和 iPhone 创建新的启动屏幕。我认为您也可以将 iPhone 4 的“假”图像用于非视网膜显示屏,并让钛来处理大小调整。

I have done the same thing with a Titanium iPad app. I found that I needed to create my own 'Splash Screen' image without the top 20px where the status bar would be. Because titanium apps can start full screen, the Default-Portrait.png assumes it could be full screen. When you add Default-Portrait.png view in a non-fullscreen app, it shifts it down 20px and you get that 'shifting' effect to the user.

Since you are running on iPhone and iPad, you will probably need to create new splash screens for iPad and iPhone. I would think that you could use the iPhone 4 'fake' image for non retina displays as well and let titanium handle the resizing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文