How to load view if UIViewController is having more than one UIView
In my app i have one UIView开发者_如何学运维Controller and there are many UIView which i want to load on particular action (for instance BTN Tap) so how can i achieve this programatically . if any one has solution please let me know.
Thnx in advance
you can bind all the views using IBOutlet like suppose you have view1 and view2 and one default view. Now you want to display view1 on btnTap then you can do like this [self.view addSubview:view1]; make sure to bind the view using IBOutlet
You can use the addSubview
method of UIView
, like this:
[controller.view addSubview:subview];
where controller
is your UIViewController
(of course, if you are putting that code inside of it, your controller is self
).
精彩评论