需要UINavigationController吗?

发布于 2024-08-11 06:16:35 字数 540 浏览 3 评论 0原文

我是一名初露头角的 iPhone 开发人员,正在尽我所能,但我对 UINavigationController 有疑问。

我有一个标签栏应用程序,有 3 个标签。

  • 第一个选项卡有五个 UIButton,每个加载应用程序的不同“部分”,每个部分将有多个视图。

  • 其他选项卡仅显示一些信息。

  • 当用户在我的第一个选项卡上选择任何 UIButton 时,我正在使用 [self.view addSubview: xxxxx];

当用户离开此视图时,我使用 [self.view removeFromSuperview];

我的问题是:

这是一种不好的做事方式吗?我应该使用导航控制器吗?我没有使用它的原因是因为我想要一个自定义的 UI,并且我知道导航控制器会稍微强制您的设计。

最重要的是,我将使用核心数据来实现持久存储......我实现此应用程序的方式会导致核心数据出现问题吗?

任何有关此的帮助将不胜感激。

干杯

汤姆

Im a budding iphone developer, and doing my best but i have a query regarding the UINavigationController.

I have a tab bar app, with 3 tabs.

  • The 1st tab has five UIButtons, each loading a different "section" of the app, and each section will have a number of views.

  • The other tabs simply display some info.

  • as users select any of the UIButtons on my first tab i am using [self.view addSubview: xxxxx];

and as users navigate away from this view i use [self.view removeFromSuperview];

My question is:

Is this a bad way to do things? should i use a navigation controller? The reason i have not used one is because i wanted a custom looking UI and i understand that the navigation controller forces your design a little.

And on top of that i will be using core data to implement persistent storage.... will my way of implementing this application cause an issue with core data?

Any help regarding thsi would be highly appreciated.

Cheers

Tom

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

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

发布评论

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

评论(2

路还长,别太狂 2024-08-18 06:16:35

首先,如果您不需要导航控制器,那就不要使用它。你不应该为此感到难过。也就是说,我认为 UINavigationController 根本不会向您强加特定的 UI。隐藏导航栏并实现您喜欢的任何 UI 非常容易。 UINavigationController 所做的事情是模块化设计:每个视图都由单独的视图控制器管理并占据整个屏幕。只有您可以回答此设计是否适合您的应用程序。如果是这样,并且您的应用程序是围绕视图层次结构设计的,那么导航控制器可能是一个不错的选择。

First, if you don't need a navigation controller, then don't use it. You shouldn't feel bad about it. That said, I think UINavigationController doesn't impose a specific UI on you at all. It's very easy to hide the navigation bar and implement any UI you like. The thing that UINavigationController does impose is a modular design: each view is managed by a separate view controller and takes up the full screen. Only you can answer if this design is suitable for your app. If it is and if your app is designed around a hierarchy of views, a navigation controller is probably a good choice.

帅冕 2024-08-18 06:16:35

正如您所说:当点击五个按钮之一时,用户将导航到另一个视图,并且五个按钮消失。这就是导航控制器的设计目的,它可以帮助您比简单地添加和删除视图更好地管理内存(取决于添加/删除的视图数量,它也可能在性能上更好)。正如 Ole 指出的那样,NavigationController 是高度可定制的,并且不会强加太多。

NavigationController 为您提供了更大的灵活性:假设您想在 2.0 版本中点击其中一个按钮后添加另一个层次结构级别。然后你会发现你的MainView会随着你不断地添加视图而不断增长。 UINavigationController 使您的代码保持良好的结构,并允许您稍后扩展导航。

CoreData 非常灵活且独立于 UI。您不必担心这一点。

As you said: when one of the five buttons is tapped the users is navigating to another view and the five buttons disappear. This is what the navigation controller is designed for and helps you manage the memory better than simply adding and removing views (depending on how many views are added/removed it might also be better on performance). As Ole points out the NavigationController is highly customizable and doesn't impose much.

A NavigationController gives you more flexibility down the road: say you want to add another hierarchy level after one of the buttons has been tapped in version 2.0. Then you will find that your MainView will be growing as you keep adding views to it. A UINavigationController keeps your code well structured and lets you extend the navigation later one.

CoreData is very flexible and UI-independent. You shouldn't have to worry about this.

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