I have the line of code below... How would I modify it to insert the subview in the superview's view named 'foo'?
[[self superview] addSubview:copy3];
I have the line of code below... How would I modify it to insert the subview in the superview's view named 'foo'?
[[self superview] addSubview:copy3];
There are more than 1 ways of doing this -
1.have an
IBOutlet
reference in your code. This is created from xcode Interface builder. Once you have this then it fairly straight forward -2.
tag
the view that you are interested in. Again tagging a view can be done from xcode Interface builder or from code. After that -3.Finally you can iterate through all the views in your superview & see which one is of type
Foo
-hope these methods help you...
First make myView into a property of the superview Then use
First tag the view myView with a unique number:
Then you can find it using viewWithTag:
You might just actually add it to 'view' instead of 'superview'.
It works just fine for me, whenever I add subviews to my parent view. Let me know if something went wrong.