Biranchi
Biranchi

Reputation: 16327

Adding UIScrollView using interface builder

I am adding a UIScrollView as a subview to the controllers view. After that i am adding 2 views to the scroll view as the content view.

When I am printing the subviews of the scroll views using NSLog(@"Scroll View Subviews : %@", [scrollViewObj subviews]);

then it is displaying 4 subviews , 2 for the views added to the scroll view and it is automatically adding 2 image views ?

I cann't get why the image views are added as subviews to the UIScrollView ? I am adding the Scroll view and 2 views to the scroll view using the interface builder.

thanks.

Upvotes: 2

Views: 2022

Answers (3)

Ashley D'Andrea
Ashley D'Andrea

Reputation: 5159

The two extra subviews are indeed for the scrollbars. You'll only see those in there if you opt to use anything other than the default scrollbars.

If you want to know the number of your own subviews, set the tag property on each one before adding it in (to a positive integer, for instance). That way you can walk the subviews and see which ones have a tag value > 0.

Upvotes: 1

Sebastian Celis
Sebastian Celis

Reputation: 12195

I bet those are used for the scroll indicators to the right and bottom of the view.

Upvotes: 2

Rob
Rob

Reputation: 26354

I'm sure UIScrollView has a bunch of child views that are part of how it functions. I wouldn't worry too much about it.

Upvotes: 0

Related Questions