I am against the same problem, and I'm starting to think about looking at the values โโof these two UIImageView to find out if they are them or not. they have a rather unique signature:
<UIImageView: 0x8ab3e00; frame = (313 812.5; 7 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x8ab9740>> <UIImageView: 0x8ab3e90; frame = (314.5 522; 3.5 341); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x8ab3f20>>
among other hooks that you could listen to. not perfect, but not many options at this stage ...
Here is an example. in this case, I was scrolling through scrollview proxies to determine the optimal contentSize height for scrollview based on subzones when it started coming out with some funky values โโthat make me think that these were scrollbars, I ...
CGRect contentRect = CGRectZero; for (UIView *view in self.myScrollView.subviews) {
if checking the frame of each UIView is not enough for you, you can also make sure that it is a UIImageView.
I think this is the only "true" solution at this stage. I personally would not need to support another array of views.
EDIT:
here is my consolidated method that I use:
-(bool)isProbablyAScrollBar:(UIView*)view { CGFloat screenScale = [[UIScreen mainScreen] scale]; return (([view isKindOfClass:[UIImageView class]]) && (view.frame.size.width <= (screenScale*3.5f) || view.frame.size.height <= (screenScale*3.5f))); }
MrTristan
source share