我想列出UIViewController
中的所有子视图.我try 了self.view.subviews
,但并不是所有的子视图都列出了,例如,UITableViewCell
中的子视图没有找到.知道吗?
我想列出UIViewController
中的所有子视图.我try 了self.view.subviews
,但并不是所有的子视图都列出了,例如,UITableViewCell
中的子视图没有找到.知道吗?
必须递归地迭代子视图.
- (void)listSubviewsOfView:(UIView *)view {
// Get the subviews of the view
NSArray *subviews = [view subviews];
for (UIView *subview in subviews) {
// Do what you want to do with the subview
NSLog(@"%@", subview);
// List the subviews of subview
[self listSubviewsOfView:subview];
}
}