Each Application can define a launch function, which is called as soon as all of your app's classes have been loaded and the app is ready to be launched. This is usually the best place to put any application startup logic, typically creating the main view structure for your app.
每个 Application 对象都会定义一个 launch 函数,它将会在你应用程序所需的全部 class 加载完成,且应用程序已经做好准备的情况下执行。一般来说这里就是你用来放置应用程序启动逻辑的最好位置了,比如你可以在这里为你的应用创建主要 view 框架。
In addition to the Application launch function, there are two other places you can put app startup logic. Firstly, each Controller is able to define an init function, which is called before the Application launch function. Secondly, if you are using Device Profiles, each Profile can define a launch function, which is called after the Controller init functions but before the Application launch function.
除了 Application 中的 launch 函数之外,还有两个地方可以放置启动逻辑:第一,每个 controller(控制器)都可以定义一个 init 函数,这个函数将会运行在 application 的 launch 运行之前;第二,如果你使用了设备 profile ,每一个 profile 都可以定义一个 launch 函数,他将会在 controller(控制器)的 init 之后和 application 的 launch 之前被调用。
Note that only the active Profile has its launch function called - for example if you define profiles for Phone and Tablet and then launch the app on a tablet, only the Tablet Profile's launch function is called.
注意只有活动 profile 的 launch 函数才会被调用,比如你分别定义了 phone 和 tablet 的 profile ,现在是在 tablet 上运行它,那么只有 tablet profile 中的 launch 函数会被调用到。
1.
Controller#init functions called Controller 的 init 首先被调用 Profile#launch function called 其次是当前 Profile 的 launch 被调用 Application#launch function called 然后 Application 的 launch 被调用 Controller#launch functions called 最后是其他 controller 的 launch 被调用
2.
3.
4.
When using Profiles it is common to place most of the bootup logic inside the Profile launch function because each Profile has a different set of views that need to be constructed at startup. 当使用 profiles 的时候,最好把启动逻辑代码放在 profile 的 launch 里面,因为每个 profile 可能需要调用不同的 view 来构建启动界面。
Routing and History Support 路由和访问历史支持
Sencha Touch 2 has full Routing and History support. Several of the SDK examples, including the Kitchen Sink, use the history support to enable the back button to easily navigate between screens - especially useful on Android.
ST2 具有完整的路由和访问历史支持,SDK 中的好几个例子,包括 Kitchen Sink ,都使用了历史路径支持,以实现通过 back 按钮可以轻易的在屏幕之间回退导航,这一点在 Android 上尤其有用。
There will be full documentation on the history support from beta 1 onwards. As of 2.0.0 PR4 the best place to learn about Sencha Touch 2's history support is kitchen sink example, which features lots of documentation on the routing and state restoration required for history support. Beta 1 中有关于访问历史支持的完整文档,对于 2.0.0 PR4 来说,学习 ST2 的这个功能的最好地方是 Kitchen Sink 例子,这个例子在路由和状态返回等需要访问历史支持的地方有很多说明。
Further Reading 延伸阅读
There are several more guides on using the application architecture with Sencha Touch 2: 关于 ST2 的应用程序架构方面,还有几个其他的学习页面供参考。
?
Controllers 控制器
Device Profiles 设备配置
?
全文完,尊重他人劳动,转载请注明出处,有问题烦请指正,多谢。