Add a UIview to an UIViewController
I'm a beginner in Iphone 开发者_如何学JAVAdevelopment. I have a project with a single openGL View.
I already wrote an UIView Controller class. but I don't know how to add the view to the UIViewController, and how to integrate the UIViewController to the project. Also, I don't know
Any help, similar example, or link to a tutorial is very appreciated. Thanks.
UIViewController has a "view" property. If you want your openGL View to be the base view for the controller you would assign it like so.
myViewController.view=myOpenGLView;
If you want the openGL view to be a subview of the controllers main view you would assign it thusly:
[myViewController.view addSubview:myOpenGLView];
The important thing to remember is that the view controller is not itself a view. To add and remove views or to refer to views you use the controller's view property. UIView has the methods specifically for managing the view hierarchy.
精彩评论