How can I see the components of a view inside another view How can I see the components of the main view:
NSArray *sub = [self.view subviews];
if ([sub count] == 0) return;
for (int i=0; i<sub.count; i++){
NSLog(@"Subview: %@", sub[i]);
}
And if it gives me the components that view has, but what happens if that view has another view inside with other subviews, how can I identify them, try:
NSArray *sub = [self.view subviews];
if ([sub count] == 0) return;
for (int i=0; i<sub.count; i++){
if ([sub[i] isKindOfClass:[UIView class]]) {
NSArray *sub1 = [sub[i] subviews];
for (int x=0; x<sub1.count; x++){
NSLog(@"ssssssss:::::::::::%@", sub1);
}
}
}
But it's not that it doesn't work, but it recognizes the buttons as SUBVIEW and it pulls the component that it has inside, let's say that if the button has an image it tells me that it has a UIImageview inside and if it has text a UIButtonLabel they explain what is happening and like getting only the ones that that UIView has at the moment, ONLY the UIView's.
Well, as always, I'm the only crazy person who always answers your questions. What happens, I discovered that the UIIbutton works as a UIView in addition to the UIButton because to store text or an image they work with a UIView generating a new subview either of type UIImageview or UIButtonlabel.
There seems to be no way around that so I fixed it with a simple condition.
The rest is self explanatory.