从 Android 应用程序、UIViews 或 UIViewControllers 创建 iPhone 应用程序?
我对 iPhone 编程还很陌生。我是我们公司唯一的 Objective-C 程序员,我必须创建一个几乎为 Android 但为 iPhone 完成的应用程序。
我有两个基本问题。该应用程序有很多屏幕、一个大的视图层次结构以及用于在视图之间移动的按钮。
问题 1:由于我需要一个后退按钮来返回到上一个视图,因此使用 UINavigationController 拥有 30 或 40 个视图控制器并拥有一个后退按钮是一个好主意吗?或者拥有大约 6 或 7 个视图控制器,每个视图控制器有多个视图会更好? [这个问题也是考虑内存管理]
和问题2:如果最好的选择是有6个视图控制器,每个视图控制器有很多视图,我怎样才能实现后退按钮就好像它是一个 Android 应用程序(或者 UINavigationController 但对于 UIViews 来说)?
非常感谢您提前的回答,我知道内存管理是iPhone编程中非常重要的问题,这是我的同事(android程序员)没有的问题,而后退按钮是另一个大问题我取决于应用程序编程的方式。
多谢!!
I'm quite new in iPhone programming. I'm the only objective-c programmer of my company, and I have to create an app almost done for android but for iPhone.
I have 2 basic questions. The app has a lot of screens, a big hierarchy of views and buttons to move between the views.
Question 1: As I need a back button to go back to the previous view, is it a good idea to have like 30 or 40 view controllers and have a back button by using the UINavigationController? Or it would be better to have around 6 or 7 view controllers with many views for each view controller? [This question is made also thinking about memory management]
And Question 2: in the case that the best choice would be have 6 view controllers with many views for each view controller, how can I implement a back button as if it would be an Android app (or a UINavigationController but for UIViews)??
Thank you very much for your answers in advance, I know that memory management is a very important issue in the iPhone programming, a problem that my work-mates (android programmers) don't have, and the back button, another big problem for me depending on the way of programming the app.
Thanks a lot!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于内容的每个“屏幕”,您应该有一个视图控制器。
You should have one view controller for each "screen" of content.
在大多数情况下,关键是您自己控制内存,并确保您释放在给定时间不需要使用的内容。仔细维护对象应该可以限制您将遇到的任何内存问题,即使有大量控制器从堆栈中推入和弹出。
就您应该使用多少个控制器而言,这会有所不同。任何以基本方式复制功能的屏幕(编辑单个文本字段、显示图像等)通常可以共享控制器,并在推送它们之前对其进行一些属性魔法。
然而,如果您的每个屏幕都非常独特,那么拥有多个视图控制器根本不会对您造成伤害。
For the most part, the key is going to be controlling memory yourself, and ensuring that you're releasing content that doesn't need to be used at a given time. Careful maintenance of your objects should limit any memory issues you're going to have, even with numerous controllers pushing and popping from the stack.
In terms of how many controllers you should use, this is going to vary. Any screens that duplicate functions in a basic way (editing a single text field, displaying an image, etc) can usually share controllers with a little property magic worked on them before you push them.
If each of your screens is very unique, however, then having a number of view controllers won't hurt you at all.