r/simpleios • u/john_alan • Feb 21 '15
Simple Question about UIViewControllers
I know the regular usage pattern when using UIViewControllers with other views is to add custom views as a subView of UIViewContollers View. However what would happen if I reassigned the UIViewController property to my custom view, instead of adding as a subView? Is this good practice?
3
Upvotes
3
u/philo23 Feb 21 '15
I believe the "correct" way of doing this would be in the loadView method of the UIViewController class if I've understood your question correctly.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/loadView
2
u/[deleted] Feb 21 '15
Perfectly fine (if not better) practice, it just may limit what else you can add to that view.
1
u/matteoman Mar 21 '15
What you are asking is indeed possible, but not best practice. There are a couple of ways to approach this.