在没有 UINavigationController 的情况下应该使用 UIViewController 吗?
总结
从概念的角度来看,即使您没有使用 UINavigationController,也应该使用 UIViewController 子类及其 Nib 吗?
场景
我尝试开发的应用程序没有 UINavigationController。我主要查看一个特定 UIScrollView 实现中的元素,如果存在“下一级导航”,它只会改变一个小元素的外观以显示更多细节。元素的详细视图(不同的元素生成不同的视图)在 Interface Builder 中布局,为此我选择使用相应的 XIB 文件创建新的 UIViewController 子类。
疑问
在探索让这些实例以动画方式呈现在视图中的不同方法时,我遇到了许多使用 UINavigationController 的解决方案。 UIViewController 本身似乎已经面向协同作用。有一个 self.navigationController,以及许多在线示例,说明如何在有或没有动画的情况下推送和弹出。
问题
所以我现在想知道的是“我做对了吗?”谷歌搜索这个问题的答案只会给我带来更具体的实现示例,所以我决定发布这个。
我是否应该限制自己使用 XCode 的“新文件”模板来创建带有 XIB 的 UIViewController 子类?或者我应该在我的应用程序中实现 UINavigationController,即使没有进行全屏导航?
我非常感谢您的启发。 干杯, 埃里克-保罗.
Summary
From a conceptual point of view, should one be working with UIViewController subclasses and their Nibs, even if you're not using the UINavigationController?
Scenario
The application I'm trying to develop has no UINavigationController. I'm mostly looking at elements in one particular UIScrollView implementation, and if there's at all a 'next level of navigation', it merely alters the appearance of a small element to show more details. The detail views of the elements (different elements spawn different views) are laid out in Interface Builder, for which I opted to create new UIViewController subclasses with corresponding XIB files.
Doubt
While exploring the different ways I could have these instances animate into view, I come across a lot of solutions using the UINavigationController. The UIViewController itself already seems to be geared towards the synergy. There's a self.navigationController, and lot's of examples online of how to push and pop with and without animation.
Question
So what I'm wondering right now is "did I do the right thing?" Googling an answer to that question only brought me to more specific implementation examples, so I decided to post this.
Should I have restrained myself in using XCode's "new file" template for UIViewController subclasses with XIB? Or should I have implemented a UINavigationController in my app, even if there's no screenfulls of navigation going on?
I'd be much obliged for enlightenment.
Cheers,
Eric-Paul.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIViewController 是一个有用的工具。它提供内存管理、界面旋转的锚点等等。如果需要,它们可以被推送到导航控制器(如果不是现在,也许以后),可以是选项卡栏控制器的页面,或者在 iPad 上的弹出窗口中表现良好。
它们价格便宜,而且我没有理由不使用它们。无论如何,您的代码都需要去某个地方。不要淹没应用程序委托或视图。
UIViewController is a useful tool. It offers memory management things, anchor points for interface rotation and lots more. If needed, they can be pushed to a navigation controller (if not now, maybe later), could be a page of a tab bar controller, or behave well in popovers on iPad.
They come cheap and I don't see a reason not to use them. And your code needs to go somewhere anyway. Don't flood the application delegate or the view.