addSubview 显示黑屏,没有内容 - iPhone

发布于 2024-12-12 19:31:17 字数 275 浏览 3 评论 0原文

当我加载 xib: AboutViewController 作为视图 contentView 的子视图时,我只是得到一个空白的黑屏,有人可以帮忙吗?

UIView* moreView = [[[NSBundle mainBundle] loadNibNamed:@"AboutViewController" owner:self options:nil] lastObject];

    [_revealView.contentView addSubview:moreView];

When I load my xib: AboutViewController as a subview of the view contentView, I just get a blank black screen, can someone help??

UIView* moreView = [[[NSBundle mainBundle] loadNibNamed:@"AboutViewController" owner:self options:nil] lastObject];

    [_revealView.contentView addSubview:moreView];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-12-19 19:31:17

您应该使用视图控制器,然后只访问视图控制器的视图:

UIViewController * aboutVC = [[UIViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
[_revealView.contentView addSubview:aboutVC.view];

或者,您可能有兴趣以模态方式呈现视图:

[_revealView.contentView.viewController presentModalViewController:aboutVC
                                                          animated:(BOOL)animated];

如果您不使用 ARC,则必须手动管理 aboutVC与保留和释放。

You should use view controllers instead, then just access the view of the view controller:

UIViewController * aboutVC = [[UIViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
[_revealView.contentView addSubview:aboutVC.view];

Alternatively, you may be interested in presenting the view modally:

[_revealView.contentView.viewController presentModalViewController:aboutVC
                                                          animated:(BOOL)animated];

If you are not using ARC, you will have to manage aboutVC manually with retain and release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文