for (id obj in self.view.subviews) {
if ([obj isKindOfClass:[UIButton Class]]) {
UIButton* theButton = (UIButton*)obj;
theButton.xxx = ooo;
}
}
为什么在控件上遍历子控件时我们要在 for in 中取 id 属性再做 if ([obj isKindOfClass:[UIButton Class]])判断而不能直解取 uibutton ,像下面这样:
for (id obj in self.view.subviews) {
UIButton* theButton = (UIButton*)obj;
theButton.xxx = ooo;
}
if ([obj isKindOfClass:[UIButton Class]]) {
UIButton* theButton = (UIButton*)obj;
theButton.xxx = ooo;
}
}
为什么在控件上遍历子控件时我们要在 for in 中取 id 属性再做 if ([obj isKindOfClass:[UIButton Class]])判断而不能直解取 uibutton ,像下面这样:
for (id obj in self.view.subviews) {
UIButton* theButton = (UIButton*)obj;
theButton.xxx = ooo;
}