开发者

How to separate different parts of an iPhone views?

I have a common header and common footer in all the view controllers of an开发者_C百科 iPhone application. What I want to do is, I want to separate the header and footer into different nib, .h and .m files and want to integrate these into one view.

How to do that?

Thanks all. Guru


You can create 2 UIViewController(s):

  • HeaderViewController.m (with .h and .xib)
  • FooterViewController.m (with .h and .xib)

Then in you view you add them by code: (Or via Interface Builder if you want)

HeaderViewController *header = [[HeaderViewController alloc] init];
[header setFrame:CGRectMake(0,0, 320, 100)]; // For example
[self.view addSubview:header.view];

In IB: Add a new UIViewController in IB, change the classe UIVIewController by HeaderViewController, link it with an IBOutlet (header), then you just have to do [self.view addSubview:header.view];.

How to separate different parts of an iPhone views?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜