ViewWithTag returns itself

I have weird behavior with the viewWithTag function. My storyboard looks like this:

  -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 am my code, I do [UIScrollView1 wiewWithTag: (1 to 11)] (every time it throws like a good object and it works well. I do the same with UIScrollView2, but viewWithTag returns UIScrollView2 every time, so I never map any marked object.

For debugging purposes only, I do not update UIScrollView2 and try to update some other value of UIScrollView1, and it returns UIScrollView1 for only one object - UIImageView (single). But all UILabel work fine again.

Anyone have any tips to help me?

PS: Tag objects were checked as 10 times, and I use a function like: - (void) updateWithScroll: (UIScrollView *) myScroll so this is the same as 1 or 2: (

Thanks in advance,
Damien

+4
source share
2 answers

Try looking at subheadings yourself with quick enumeration of subviews or with another loop.

I ran into the same problem while I did not expect this behavior, but I have the choice not to save the root view tag and set it to -1, the value has never been used.

+1
source

I assume that the UIScrollView2 tag is 0, so the first view with the 0 tag is your UIScrollView2.

You should probably specify a different tag for each subset of your UIScrollView2 and always be different from the UIScrollView2 tag.

For example, you can save 0 for your scrollView tag and 1,2,3 ... for it subviews.

0
source

All Articles