mvc模式在iOS用户界面中是如何实现的? (基于视图的 XCode 模板)
我是 iPhone 开发新手。有很多关于这个主题的书籍。但大多数初学者指南主要关注 Interface Builder 的使用,缺乏有关现有内置 XCode 代码模板的信息或可以帮助我理解代码中的 MVC 实现的信息。我发现根本不需要 ViewController 就可以编写有效的 iOS 程序。嗯,在我看来,在使用名为 ViewTransitions 的示例代码之后,情况就是这样。
所以,问题是 - 为什么可以避免在具有按钮界面的程序中实现 ViewController?如果答案太长,您能否推荐涵盖该主题的教程或手册。
提前致谢。
I'm new to iphone development. There's a lot of books on this topic available. But most of the beginner's guides are mostly concerned with Interface Builder usage and lack the information about existing built in XCode code templates or something that could help me in understanding MVC implementation in code. I found that it is possible to write working iOS program without ViewController at all. Well, it seems to me like that after working with the sample code called ViewTransitions.
So, the question is - why is that possible to avoid ViewController implementation in a program that has an interface with a button? If the answer is going to be too long, could you please recommend kind of tutorial or manual covering this topic.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
@user697562 的答案本质上是正确的:在 ViewTransitions 的情况下,控制器的角色由应用程序委托扮演。该应用程序几乎不执行任何操作 - 它只是在两个视图之间切换以演示几种可能的过渡效果 - 因此那里并不真正需要 UIViewController。
请注意,ViewTransitions 中也没有任何东西可以真正称为模型对象。如果您正在寻找 MVC 的强大示例,ViewTransitions 并不是最好的项目。其他示例项目(例如 TheElements)更好地演示了 MVC 的实际应用。
@user697562's answer is essentially correct: in the case of ViewTransitions, the role of the controller is played by the app delegate. The app does next to nothing -- it just switches betweeen two views to demonstrate several possible transition effects -- so a UIViewController isn't really needed there.
Notice that there's also nothing in ViewTransitions that you could really call a model object. If you're looking for a strong example of MVC, ViewTransitions isn't the best project to look at. Other sample projects, such as TheElements, give a better demonstration of MVC in action.