views:

1410

answers:

3

Hi ,

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.

A: 

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.

unforgiven3
+2  A: 

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

Sebastian Celis
I would think of the subviews array as being like the retainCount: don't worry too much about it; you'll only end up more confused.
Alex
yes i think the scroll indicators are added as the subviews...
Biranchi
+1  A: 

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.

Joe D'Andrea