0

I am trying to calculate a value from UIScrollView's subviews (subviews added by user). Problem is UIScrollView also has its own subviews by default;

UIKIT_CLASS_AVAILABLE(2_0) @interface UIScrollView : UIView <NSCoding> {
    ...
    UIImageView* _verticalScrollIndicator;
    UIImageView* _horizontalScrollIndicator;

I would like to discard these subviews and calculate my value with the subviews only added by user. How can I detect and discard these above mentioned UIImageViews while iterating through scrollView.subviews (NSArray)

8
  • Tag all your subviews with a custom tag number... What class are your subviews, how can you make them stand out ? Can you hold an array with references to all your subviews ?
    – Wain
    May 27, 2013 at 16:29
  • I am creating a category implementation. That wouldn't be practical
    – Bartu
    May 27, 2013 at 16:29
  • So what have you considered and ruled out and why. Don't make us guess.
    – Wain
    May 27, 2013 at 16:31
  • I haven't figured out what to do :) so haven't tried anything.
    – Bartu
    May 27, 2013 at 16:32
  • 1
    I think UIScrollView shouldn't be used that way. You are supposed to add just one content view to it, not multiple views. If you need multiple subviews, add these subviews to the content view and iterate over contentView.subviews instead of scrollView.subviews. Further, if you rely on private implementation details like _verticalScrollIndicator, your implementation might break in future versions of iOS.
    – Theo
    May 27, 2013 at 17:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.