如何使用 Titanium 查询父视图的子视图? [英] How to query the child views of a parent view using Titanium?

查看:23
本文介绍了如何使用 Titanium 查询父视图的子视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建一个通用例程,该例程将对视图的子项进行操作.在例程中,我需要能够迭代子视图.我在 API 中没有看到任何表明有任何方法可以获取子视图的内容.有一个add()"和一个remove()"方法,但没有像get()"这样的方法,也没有像views"这样的任何属性.我错过了什么?

I am looking to create a general purpose routine that will operate over a view's children. Within the routine I need to be able to iterate over the child views. I don't see anything in the API that would suggest that there is any way to get the child views. There is an "add()" and a "remove()" method but nothing like "get()" nor does there appear to be any properties like "views". What am I missing?

推荐答案

这是从视图中移除子对象的基本结构

this is the basic structure for removing child objects from a view

    if (view.children) {
        for (var c = view.children.length - 1; c >= 0; c--) {
            view.remove(view.children[c]);
        }
    }

这篇关于如何使用 Titanium 查询父视图的子视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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