0

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.

MarshR8
  • 11
  • 3
  • 1
    Assuming you're using a storyboard (or xib) to create this structure, put an IBOutlet in your code that connects to C from the class that manages the hierarchy. (If you're creating the structure some other way, I'd need details of that.) – Phillip Mills Apr 06 '19 at 17:59
  • Additionally you could register an observer in C and send notifications from anywhere you like. If you only need specific access from a hierarchical view you can work either with an outlet in the storyboard or with a delegate. – Pat_Morita Apr 06 '19 at 19:22

1 Answers1

0

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.

John Smith
  • 573
  • 6
  • 22