iPad 上的导航控制器

发布于 2025-01-05 23:07:10 字数 595 浏览 4 评论 0原文

我是第一次在 iPad 上工作&我注意到我无法像目前在 iPhone 上使用的那样在 iPad 上使用 UINavigationController。

这就是我正在尝试做的事情。

  • 在 AppDelegate 中使用 UINavigationBarController
  • 创建它的对象并连接它。
  • 创建 UIViewController 类 + XIB
  • 将此 XIB 设置为导航的根视图

对于 iPhone,它曾经可以工作,但在 iPad 上则无法工作。我的 viewController 的 ViewDidLoad 方法没有被调用。

有什么建议我应该做什么。

编辑:

.m navigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController];

[window addSubview:navigationController.view];

谢谢, 吉特什

I m working on iPad for the first time & I noticed that I m not able to use a UINavigationController on iPad as I have used so far on iPhone.

This is what I m trying to do.

  • Use a UINavigationBarController in AppDelegate
  • creating object of it and connecting it.
  • create UIViewController class + XIB
  • Set this XIB as navigation's root view

For iPhone it used to work but in case of iPad its not working. My ViewDidLoad method of my viewController is not getting called.

Any suggestion What should I do.

EDIT :

in .m
navigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController];

[window addSubview:navigationController.view];

Thanks,
Jitesh

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

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

发布评论

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

评论(1

回忆凄美了谁 2025-01-12 23:07:10

导航控制器在 iPad 中的工作方式应与 iPhone 相同 - 检查您是否已在 nib 文件中正确设置插座 - 还要记住您是否使用与视图控制器名称不同的 nib 名称(例如,使用 iPad 后缀来区分您的对于该 VC 的 iPhone 笔尖)您需要在视图控制器的 init 中传递笔尖名称。

(即使用)
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle

检查主笔尖中的笔尖名称和出口是否均已正确设置。

Navigation controller should work the same in iPad as iPhone - check that you've set your outlets in your nib file properly - also remember if you are using a nib name different to the view controller name (e.g. with an iPad suffix to differentiate from your iPhone nib for that VC) you need to pass the nib name on the init for the view controller.

(i.e. use)
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle

check that nib names and outlets in your main nib are all set up properly.

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