I have a custom UIview which is created programmatically. How to associate to it a custom UIViewController (programmatically as well)
Thanks and regards,
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.
Implement
loadViewin theUIViewControllerto create a view hierarchy programmatically without a nib file.You can continue setting up the view/subview hierarchy in two ways. One is to add them in the custom
UIView‘s initialization method, like so:The second way is to continue using the
loadViewmethod implemented in theUIViewControllersubclass, and just using[self.view addSubview:anotherView]. (Alternatively, use theviewDidLoadmethod in theUIViewController subclass.)Note: Replace
initWithFrame: with whatever the customUIView‘s initialization method is (e.g.,initWithDelegate:).