UINavigationController 模板

发布于 2024-08-18 08:58:51 字数 214 浏览 8 评论 0原文

当我打开新文件对话框时,我只看到 3 个 Cocoa Touch 类:Objective-C 类、Objective-C 测试用例类、UIViewController 子类。当我上次使用 Xcode 时,在更新之前,我记得有超过 3 个选项,其中包括我正在寻找的:UINavigationController。

那么在哪里可以找到这个模板来创建 UINavigatonController 子类呢?

When I open the new file dialog I see only 3 Cocoa Touch Classes: Objective-C class, Objective-C test case class, UIViewController subclass. When I last worked with Xcode, before I updated it, I remember there were more than 3 options, which included what I'm looking for: UINavigationController.

So where can I find this template to create a UINavigatonController subclass?

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

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

发布评论

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

评论(2

一世旳自豪 2024-08-25 08:58:51

Apple 对 Xcode 的文件创建屏幕进行了大量更改,这也让我感到措手不及。我不太确定您的导航控制器试图完成什么任务,但 iPhoneDevSDK 论坛上的这篇文章解释了为什么您不应该继承 UINavigationController 的子类,而应该以模态方式呈现您的视图。

iPhoneSDK 论坛 UINavigation 控制器子类化

除了论坛中关于模态视图控制器的讨论,这里是来自 Apple 视图控制器编程指南的源代码,解释了如何实现这一点。

YourViewController *viewController = [[YourViewController alloc] initWithNibName:@"YourView" bundle:nil];

viewController.delegate = self;

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];

[self presentModalViewController:navigationController animated:YES];

Apple's made a lot of changes to Xcode's file creation screen and they've caught me of guard as well. I'm not exactly sure what your navigation controller is attempting to accomplish, but this post at the iPhoneDevSDK forum explains why you shouldn't subclass UINavigationController and instead present your view modally.

iPhoneSDK Forum UINavigation Controller Subclassing

In addition to the discussion in the forum about modal view controllers, here is source code from Apple's View Controller programming guide that explains how accomplish this.

YourViewController *viewController = [[YourViewController alloc] initWithNibName:@"YourView" bundle:nil];

viewController.delegate = self;

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];

[self presentModalViewController:navigationController animated:YES];
不如归去 2024-08-25 08:58:51

UINavigationController 的头文件协议中找不到必需的方法。我不确定旧模板过去是什么样子,但您可以尝试使用旧类之一重新创建一个模板,或者只检查头文件中您想要通常实现的方法并为其存储自己的模板。

There are no required methods found in the header file protocols for UINavigationController. I'm unsure what the old template used to look like, but you could try re-creating one using one of your old classes, or just examine the header file for the methods you want to commonly implement and store your own template for it.

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