你们中的任何人都知道如何获得子视图列表吗?有没有办法将列表放入数组中?
NSMutableArray *subviews= .... //all my subviews
你可以这样做
- (void)listSubviewsOfView:(UIView *)view {
// Get the subviews of the view
NSArray *subviews = [view subviews];
// Return if there are no subviews
if ([subviews count] == 0) return;
for (UIView *subview in subviews) {
NSLog(@"%@", subview);
// List the subviews of subview
[self listSubviewsOfView:subview];
}
}
请通过此链接How to list out all the subviews in a uiviewcontroller in iOS?