How can I hook a subview of a subview?

196 Views Asked by At

The parent class A has a subview B and that subview has another subview C, this is what i want to hide or apply code to (C)

How ?

B is the third subview of A and C is the second subview of B.

They’re like this:

  1. |A

  2. ||B “UIView”

  3. ||B “UIView”

  4. ||B "UIView"

  5. |||C

  6. |||C (i want to access this)

  7. |||C

I already tried

%hook A

-(void)layoutSubviews {

for (C *view in subviews[2].subviews)

%orig;

view.hidden = YES;

%end

but no luck.

1

There are 1 best solutions below

0
John Smith On

The one way I'm thinking of is just doing subviews[0].subviews[0]... until you get the view you want. Second if you would have to apply code more than once, I'd recommend that you assign a tag to that view once and then just do [UIView viewWithTag:xx], it's much safer.

But in most cases, at least in my projects, there is a shortcut, like some delegate or reference to that directly. Just show the FlexFlipboard Browser and search through everything.