nikhil challagulla
nikhil challagulla

Reputation: 33

List the tag of Subviews which are visible in a UIview

I have UIView, Initially i will have 4 subview, in runtime. my code will hide to 2 view, so i need the tag values of remaining two view which are visible, is it possible.

Please help me.

Thanks, Nikhil.Ch

Upvotes: 0

Views: 59

Answers (1)

Xchord
Xchord

Reputation: 688

First, iterate the subviews of the view. Check if the subview is a UIView class. From here, you can now check whether the subview is hidden or not.

for (UIView *subview in self.view.subviews) {
    if ([subview isKindOfClass:[UIView class]]) {
        if (!subview.isHidden) {
            NSLog(@"%i", subview.tag);
        }
    }
}

Upvotes: 1

Related Questions