Adding subview to a subview from another method
Let me start off by describing my situation. I have a main view that I wish to place a smaller scrollview subview in. Then later in code (in another method), I like to add some subviews (images and textviews) to that scrollview subview. And maybe even remove the image- and text-subviews later (in yet another method). So the image- and text-subviews ends up been a subview of a subview of th开发者_StackOverflow社区e main view.
This is easily done, if it all happens inside the same method. But I can't seem to add a 3rd generation subview to the second subview from another method. Would expect something like:
[self.view.scrollviewSubview addSubview:anotherSubview];
How to target the scrollview-subview placed as subview in main view. Hope my question makes sense, it's really hard to describe in text.
I'm not sure to have understood ^^
But if your problem is to access a subview you don't have a pointer to, maybe you could set a tag to your subview
[ view setTag:9000 ];
Then later in your code you could search for this view with :
[ view viewWithTag:9000 ]
Don't forget that with viewWithTag you will get an UIView class. So if you need to get a specific class, you should cast it like
(MyViewSubclassed*)[ view viewWithTag:9000 ]
Good Luck !
精彩评论