how to add a UIView file on a MainView as a subview

If I already have a UIViewController(no nib) on iphone,and I wanna use it on ipad. I use a IBOutlet(UIView)on ipad to show this view.

I try to set in viewDidLoad :

MacroMainView *marcoview =[[MacroMainView alloc]initWithNibName:nil bundle:nil];

marcoView =[marcoview view];

[[self view]addSubview:marcoView];

but still no work.. What should I do??

Thanks in advance.


You should use loadView method for a UIViewController without a nib. UIViewController Doc

If you create your views manually, you must override this method and use it to create your views

链接地址: http://www.djcxy.com/p/87756.html

上一篇: UIViewController的子类立即释放

下一篇: 如何在MainView上添加一个UIView文件作为子视图