Can I load a UiViewController in a UIView in another UIViewcontrller.
suppose UIViewControllerA has a UIView named subuiview. Can I load UIViewControllerB into subbuiview?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Starting with iOS 5
“Container view controllers” have been added in iOS 5. You can add a view controller as a child of another one with
addChildViewController:.You also are responsible for adding its view to its parent’s view.
Everything is well documented in the iOS SDK documentation: Implementing a Custom Container View Controller.
To add a child view controller:
and to remove it:
Prior to iOS 5
It’s possible to load another view controller and add its view as a subview of another controller’s view.
Although it’s not recommended by Apple’s guidelines:
(from the View Controller Programming Guide)
Your sub-controller won’t receive rotation events, or
viewWillAppear,viewWillDisappear, etc (exceptviewDidLoad).So Apple advises us to use a single view controller managing the entire view hierarchy (but doesn’t forbid to use multiple ones).
Each view may still be a custom subclass of UIView. Maybe you don’t need another view controller but rather a custom view.