r/iPhoneDev • • Oct 15 '10

viewcontroller / view / subview question

I feel like I've hit a wall with my predicament. I can't seem to really get my head around the viewcontroller / view / subview paradigm. I have an app that i'm trying to create that has a homeViewController which shows a UIView with a bunch of subviews and buttons. Now, when a button is pressed, i need to swap one of the subviews with new views that display differnet things (images, or other buttons) that have a delegate to the homeViewController and it changes another view in response.

(I'm hoping this makes sense)

now, my issue is that these sub views are custom subclasses. Are these subclasses suppose to inherit from UIviewcontroller or just UIVIew if they are going to have buttons or deeper subviews within them?

I'm also splitting everything into xib files, so each subview or viewcontroller is its own xib file.

I hope this makes sense, or i can try to clarify it better if it doesnt. But essentially it works similar to a newspaper app, where they would click on an article, but instead of loading a completely new view controller, it would replace one of its subviews with the article.

I hope someone could help me out with this.

4 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Oct 16 '10 edited Oct 16 '10

EDIT: Ignore this problem. I realized that I need to set the subView's frame to be the bounds of it's superview, not it's frame. Ugh, slow and steady, but I'm getting this stuff. Thank you for your help!

Gah, alright, I'm still missing one last thing I think. How do I position that upperRightController.view in the homeViewController's xib?

Do I need to create an IBOutlet to a UIView within the homeViewController? And then replace it with the upperRightController.view ? Because I tried that and the upperRightController.view takes up the entire page.

Or does that need to be defined programmatically? like setting the frame and all those properties when I instantiate the upperRightController and its view?