开发者

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

HI, Jus started working on ipad. I have a UIViewController application. In the main View have a button. on click of this button i need to add an UIView as a subvie开发者_Go百科w in the main view. The content of UiView subview must be loaded from a nib file. can some one help me how can this be achieved. SubView nib file is created using IB. I have MainView.xib, mainviewcontroller.h,mainviewcontroller.m , subview.xib,subview.m,subview.h.

any help or guidance will help a lot.

thanks in advance.


Here's all I had to do to make it work:

OverlayViewController *overlay = 
    [[OverlayViewController alloc] initWithNibName: @"OverlayView-iPad" bundle: nil];

UIView* overlayView = [overlay view];

[self.view addSubview: overlayView];

To one gotcha I stumbled upon was the second line - "UIView* overlayView = [overlay view]". You must access the view to trig the controller to load it. Passing self.view to the addSubview method won't do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜