将XIB加载到UIView中 [英] Load XIB into a UIView

查看:53
本文介绍了将XIB加载到UIView中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIView不能覆盖iPhone的整个屏幕...大约200像素乘300像素.

I have a UIView that is not covering the entire screen of an iPhone... about 200 pixels by 300 pixels.

我正在尝试将xib加载到此视图中,但这似乎有问题.该代码可以工作,但是UIView可以全屏显示所有内容...而不是以UIView的确定宽度为准.

I'm trying to load a xib into this view, but it seems to have an issue. The code works, but the UIView takes over everything at fullscreen... not at the determined width of the UIView.

这是我的代码:

incViewPopUP = [[[NSBundle mainBundle] loadNibNamed:@"IncidentsViewController" owner:self options:nil] objectAtIndex:0];

我还尝试将其添加为如下所示的子视图..但这也行不通.

I also tried adding it as a subview like below.. but that also does not work.

UIView *myView = [[[NSBundle mainBundle] loadNibNamed:@"IncidentsViewController" owner:self options:nil] objectAtIndex:0];
[incViewPopUP addSubView:myView];

感谢您的帮助!

推荐答案

Adam,请尝试以下操作:

Adam, try this:

MyViewController *myViewController=[MyViewController alloc] initWithNib:@"IncidentsViewController"];

[myView addSubView:myViewController.view];

[myViewController release];

只需确保XIB具有适合您的UIView的大小即可.

Just make sure after that the XIB has the right size for your UIView.

这篇关于将XIB加载到UIView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆