How to query the child views of a parent view using Titanium?

只谈情不闲聊 提交于 2019-12-01 17:18:44

问题


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?


回答1:


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]);
        }
    }



回答2:


i would check also for

if (view.children[c] !== undefined) {..}

since i already got problems with android without verifieing.



来源:https://stackoverflow.com/questions/5474953/how-to-query-the-child-views-of-a-parent-view-using-titanium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!