Do you need a way of getting all the child subviews of a parent UIView? This is my useful function:
/** Get all subviews of a type from container View.
@param class Type of subviews to remove.
@param ownerMainView UIView container.
@return Returns an array of matched child subviews.
@see showAllSubviewsOf:
@see hideAllSubviewsOf:
@see removeAllSubviewsOfClass:fromView:
*/
+ (NSArray *)getAllSubviewsOfClass:(Class)class fromView:(UIView *)ownerMainView {
NSMutableArray *arr = [[NSMutableArray alloc] init];
for (id obj in ownerMainView.subviews) {
if ([obj isKindOfClass:class]) {
[arr addObject:obj];
}
}
return [NSArray arrayWithArray:arr];
}
Download the ready-for-use source file (.m) of Get all child UIView subviews
No comments:
Post a Comment