Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

viewWithTag return self

I have a strange behavior with the function viewWithTag. My storyboard look like that :

-viewController
--UIScrollView1 (should be a UIView but not changing yet)
---Object with tag 1 to 11
---Some other object with tag 0
--UIScrollView2 (should be a UIView but not changing yet)
---Object with tag 1 to 11
---Some other object with tag 0
I my code, I do [UIScrollView1 wiewWithTag:(1 to 11)] (each time cast as the good object and it work well. I do the same with UIScrollView2 but viewWithTag return each time UIScrollView2, so I never match any tagged object.

Just for Debug purpose, I don't do UIScrollView2 update and try to update with some other value UIScrollView1, and the it return UIScrollView1 just for one object, a UIImageView (the only one). But all the UILabel work fine again.

Did someone have some clues to help me ?

PS : The tag objects was checked like 10 times and I use a function like : -(void) updateWithScroll:(UIScrollView*)myScroll so it's the same as the 1 or the 2 :(

Thanks in advance,
Damien

like image 458
Dam Avatar asked Nov 24 '25 02:11

Dam


1 Answers

Try to browse the subviews by yourself, with fast enumeration of subviews or with another loop.

I ran into the same issue while I did not expect that behavior, but I have the choice to not keep the root view tag and set it to -1, a value never used.

like image 127
Crazyrems Avatar answered Nov 27 '25 11:11

Crazyrems



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!