iOS 5故事板:每个场景的类 [英] iOS 5 Storyboards: Classes For Each Scene

查看:78
本文介绍了iOS 5故事板:每个场景的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用xCode和Objective C开发,我有一个简单的问题。在故事板中为每个场景分配单独的类文件有什么意义。

I'm new to developing with xCode and Objective C, and I have a simple question. What is the point of having seperate class files for each scene in a storyboard.

我的问题:为什么不使用默认的 ViewController故事板中每个场景的.m ViewController.h 类。对于多个场景使用相同的课程是否有任何缺点,而不仅仅是简单的组织?

My Question: Why not use the default ViewController.m and ViewController.h class for every scene in your storyboard. Are there any disadvantages of using the same class for multiple scenes other than just being plain organized?

这是一张你将进入特定场景所使用的课程的图片...

Here is a picture of where you would enter what class a specific scene is using...

http:// i .stack.imgur.com / KtGQk.png

推荐答案

ViewController是一个管理视图层次结构的类( aka..1应用程序的屏幕)

ViewController is a class that manages a hierarchy of views (aka..1 screen of the application)

当你有多个屏幕做不同的事情时,使用单独的视图控制器会更好(也更简单)

when you have multiple screens that do different things its a lot better to use separate view controllers (simpler too)

除了..如果您使用相同的类2个或更多完全不同的屏幕Apple不会接受您的应用程序提交到App Store,因为它不遵循MCV模型(碰巧me)所以最好现在把你的代码分开..当你写下它而不是在你被拒绝之后将它分开......并且必须重写大部分应用程序

besides ..if you use the same class for 2 or more completely different screens Apple wont accept your app to be submitted to the App Store because it doesn't follow M-C-V model (happen to me) so its better to separate your code now..when you write it rather than separate it after you get rejected...and have to rewrite most of the app

加上...... e logistic thing ..来自同一文件中不同类的方法令人困惑如地狱

plus..its the logistic thing..having methods from different classes in the same file its confusing as hell

也...你不能为不同的屏幕多次实现-viewDidLoad

also...you can't implement -viewDidLoad multiple times for different screens

等等......我可能会在一段时间内列出原因:)

and so on..i could go for some time listing reasons :)

这篇关于iOS 5故事板:每个场景的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆