@chenbinghua
2017-02-09T10:35:13.000000Z
字数 851
阅读 1289
iOS笔记
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self findSubView:self.view];
}
// 遍历view的所有控件
-(void)findSubView:(UIView*)view
{
for (UIView* subView in view.subviews)
{
if ([subView isKindOfClass:[UILabel class]]) {
UILabel *label = (UILabel *)subView;
if ([label.text isEqualToString:@"这是一个文本"]) {
label.text = @"修改后的文本";
}
}
[self findSubView:subView];
}
}
defineClass("ViewController", {
viewWillAppear: function(animated) {
self.super().viewWillAppear(animated);
self.findSubView(self.view());
}
}, {});
require("UILabel");
defineClass("ViewController", {
findSubView: function(view) {
var subviews = view.subviews().toJS();
for (var i in view.subviews()) {
var subview = subviews[i];
if (subView.isKindOfClass(UILabel.class())) {
var label = subView;
if (label.text().isEqualToString("这是一个文本")) {
label.setText("修改后的文本");
}
}
self.findSubView(subView);
}
}
}, {});