Sencha Touch Ext.navigation.View弹出到根目录 [英] Sencha Touch Ext.navigation.View pop to root

查看:63
本文介绍了Sencha Touch Ext.navigation.View弹出到根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Ext.navigation.View,其中已推送了一些视图.某些用户交互要求我直接回到导航视图的顶层-相当于iOS中的UINavigationController上的popToRootViewControllerAnimated:.

I have an Ext.navigation.View in which I have pushed a few views. Certain user interactions require that I go directly back to the top level of the navigation view -- the equivalent of popToRootViewControllerAnimated: on a UINavigationController in iOS.

我已经尝试过各种方法,例如:

I have tried various things like:

while(navigationView.getItems().getCount() > 1)
    navigationView.pop();

while(navigationView.canPop())
    navigationView.pop();

均无效.第一个例子似乎使我陷入无限循环,这并不奇怪.第二个示例似乎只是弹出一个视图.

Neither work. The first example seems to put me into an infinite loop which isn't too surprising. The second example only seems to pop one view off.

问题是:在Sencha Touch(版本2开发人员预览)中,在Ext.navigation.View中弹出根视图的正确方法是什么?

So the question: What is the proper way to pop to the root view in an Ext.navigation.View in Sencha Touch (version 2 developer preview)?

推荐答案

有许多临时方法可以实现这一目标.

There has been a number of interim methods for achieving this.

我正在使用的那个是弹出一个比您曾经拥有的关卡数量更高的数字.

The one I was using was to pop a number higher than the number of levels you would ever have e.g.

navigationView.pop(10);

效果很好,但我对此并不满意,但是我看到他们现在引入了一种重置方法.您可以这样称呼...

and that worked fine, but I was never happy with that, but I see they have now introduced a reset method. Which you can call thus...

navigationView.reset();

在Sencha源代码的内部(请参见下文),您可以看到它的作用与@Mithralas所说的相似,但更容易编写.

Internally within the Sencha source code (see below) you can see that it does a similar job to what @Mithralas said, but just easier to write.

// From the Sencha source code
this.pop(this.getInnerItems().length);

这篇关于Sencha Touch Ext.navigation.View弹出到根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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