【发布时间】:2018-04-19 04:27:15
【问题描述】:
我在我的 iOS 应用程序中创建了单选按钮,如下图所示。一旦用户单击任何单选按钮,我想将剩余单选按钮的图像从选中更改为未选中。
下面是我的事件监听器代码。
vwBottomContainer.addEventListener("click", function(e) {
Ti.API.info('e.source.id: ' + e.source.id);
if (e.source.id == "CheckBox") {
if (e.source.status == "unselected") {
e.source.status = "selected";
e.source.image = "/images/checked.png";
} else {
e.source.status = "unselected";
e.source.image = "/images/unchecked.png";
}
} else if (e.source.id == "TextBox") {
e.source.editable = true;
e.source.focus();
} else if(e.source.id == "radiobutton") {
var t = null;
for(t = 0 ; t < e.source.parent.parent.children.length; t++) {
e.source.parent.parent.children[t].children[0].image = "/images/radio-button_ori.png";
e.source.parent.parent.children[t].children[0].status = "unselected";
Ti.API.info('e.source: '+JSON.stringify(e.source.parent.parent.children[t].children[0]));
}
t = null;
e.source.image = "/images/radio-button_active.png";
e.source.status = "selected";
}
});
上面代码中的for循环无法将其他单选按钮的图片从选中变为非选中
你能告诉我我做错了什么吗?如果您想进一步澄清,也请告诉我。
感谢您的提前。
【问题讨论】:
标签: ios titanium parent-child appcelerator addeventlistener