第一个 iPhone 多视图应用程序 - 一些指导
我想制作一个具有 5-6 个不同屏幕和一个数据源来存储用户信息的多视图应用程序。我以前从未制作过多视图应用程序,并且我对如何开始有一个好主意,但我想听到一些有关“构建”应用程序以正确支持此功能的建议。
一个非常简单的类比可能是在网站上制作背景颜色......您可以使用纯色图像或简单地使用背景颜色样式。两者都可以完成工作,但使用该样式更容易/更高效。
我只是想确保我的起步是正确的。我应该将所有函数保留在一个类的 .m/.h 文件中吗?处理不同屏幕的最佳/有效方法是什么?
谢谢,一旦我更好地掌握了 Objective-C 和 Xcode,我一定会尽力帮助其他人。
I'm wanting to make a multiview app with 5-6 different screens and a data source to store user information. I've never made a multiview app before, and I have a good idea on how to start, but I'd like to hear some recommendations on "structuring" your app to properly support this.
A very simple analogy could be going about making a background color on a website... You could either use an image of a solid color or simply use the background-color style. Both get the job done, but using the style is a bit easier/more efficient.
I just want to make sure I'm starting off on the right foot. Should I keep all my functions in one class' .m/.h file? What's the best/efficient way to go about different screens?
Thanks, and I'll definitely try to help others out once I get a much better grasp on Objective-C and Xcode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您是 iPhone/iPad 新手,我强烈建议您查看 CS193P< /a> 讲座,它们也在 iTunes 上提供。他们很好地概述了 iPhone 编程以及如何在 Objective-C / Cocoa Touch 中完成工作。它将使任何人开始朝着正确的方向前进。
至于你的具体问题。开始编码吧。 6 个月后,你会意识到你写的所有东西都是 cr*p 并且无论如何都需要重写,但这样做是你意识到你写的东西是 cr*p 的唯一方法,所以......
一些建议,特定于多 -查看过的应用程序(几乎每个应用程序都是),我确信其他人可以对此进行扩展...
If you are new to the iPhone/iPad I highly recommend you check out the CS193P lectures, they are also avaliale on itunes. They give a good overview of iPhone programing and how things are done in Objective-C / Cocoa Touch. It will get anyone started in the right direction.
As to your specific question. Just start coding. In 6 months you'll realize eveything you wrote is cr*p and needs to be rewritten anyways, but doing it is the only way you'll realize what you wrote is cr*p so...
Some suggestions, specific to multi-viewed apps (which almost every app is) and I'm sure someone else can expand on this...
对于大多数事情来说,Apple 文档通常是一个很好的起点。尝试 这里首先。希望这有帮助,祝你好运!
The Apple documentation is often a good place to start for most things. Try here first. Hope this helps and good luck!
我曾经使用 UINavigationController。我将其创建为单例并静态访问它,以便我可以轻松地推送和弹出控制器(有一个相当好的教程 此处)。这是相当轻量级的,并且有足够的文档可以快速使用它。
然而,我使用过的最好方法是 Three20 框架的 TTNavigator。简而言之,它是一个增强的 UINavigator,可让您通过调用内部 URL 将新视图推送到屏幕上:
然后导航到控制器:
同样酷的是,以我们的方式调用 @"ac://results/"上面将参数 @"searchResults" 传递给 ResultsViewController 的 init 方法("initToView:"),正如我们在映射器中定义的那样 祝
一切顺利!
I used to use a UINavigationController. I created it as a singleton and accessed it statically so I could push and pop controllers easily (theres a reasonably good tutorial here). This is quite lightweight and theres enough documentation to get going with it quickly.
However the best approach I've used is the Three20 framework's TTNavigator. In a nutshell its a beefed up UINavigator that lets you push a new view onto the screen by calling an internal URL:
Then to navigate to a controller:
Whats also cool is that calling that @"ac://results/" the way we have above passes in the param @"searchResults" to the init method of the ResultsViewController ("initToView:") as we defined in the mapper
All the best!