Common views in viewControllers - Code re-usability

Posted by Nitish on Stack Overflow See other posts from Stack Overflow or by Nitish
Published on 2012-04-09T11:15:44Z Indexed on 2012/04/09 11:28 UTC
Read the original article Hit count: 245

Filed under:
|

I have few common views in most of my viewControllers. What I noticed is that I can reuse single code for all viewControllers which is absolutely wise. For this I decided to create a class Utils which has static methods like

+(void)createCommonViews:(float)yAxis:(NSString*)text;  

In my case common views are three labels and two images.
Problem : I am not able to add these views from Utils. I am wondering how can I send self as a parameter so that I may add the views from Utils. It may be wrong to add views outside the viewController. In that case what can be the solution? Taking all these views in a UIView, setting return type of Utils method as UIView and then adding UIView to viewController(after calling method from viewController) might solve my problem. But what I am looking for is some other solution.
Thanks,
Nitish

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios