Should I be using
UIViewController-derived classes to
separate the screen-by-screen
functionality of my app?
是的。
And would my app essentially hand
control over to one of these view
controllers which would then construct
my scene with its components?
是的,尽管许多甚小部族只是从一根ni树中找到自己的观点,并关心核心控制者的责任: 1. 将模型变化传播到各种观点领域;2. 将视线活动重新纳入有关模型的适当行动。 我建议打上InterfaceBuilder的hang。 它不完美,不耐烦,但可以节省你工作时间和重新制定法典。
我如何转向相关观点控制者?
多种方式:
- If your VCs are hosted in a navigation controller,
[[self navigationController] pushViewController:theNextVC animated:YES]
is a common idiom.
- Switching among a set of VCs, where there s no clear hierarchy among them, is best done with a
UITabBarController
.
- If you want to do modal stacking,
[self presentModalViewController:theNextVC animated:YES]
is how. Modal stacks deeper than one or two get unwieldy though.
- Presenting the very first VC is done in 4.x by assigning it to your window s rootViewController property (the app delegate can do this, or the main nib can); or for pre-4, the traditional way usually found in the app delegate:
[myMainWindow addSubview:[myInitialVC view]]
.
- a few specialized apple-provided VCs (video, photo picker) have their own presentation methods.
请注意,如果你想要的是行为,而不是国际船舶和公司,那么你就可以躲藏航道或刺酒吧,并在方案上尽力。
我应期望装货 由此而来的看法?
这份清单是,但大多数你的“现在看来”逻辑都属于view WillAppear:
(在过渡估算开始之前,如果观点尚未成熟的话)和viewDidAppear:
。 (在估算之后,当观点完全可见时) 载荷
,在您的维也纳国际中心认为不久将需要时,即被点击。
Override loadView
when you want to completely replace nib loading with some other view tree construction method. I started out doing this, but rarely do so anymore.
Override viewDidLoad
当你仍然想要达到正常的硝酸 load时,也想把树木建设/后处理视为你们自己的树。 这是我发现的99%的时间。
当某些触发因素要求去做时,例如,屏幕B,是否呼吁转变我的意见,然后呼吁其他一些观点控制者阐述你们的看法,并将其过渡?
如果你使用前面列出的任何介绍方法,就会向你们过渡。 你们都需要做的是,在情况发生时,要告诉大家。
不妨调查“要素”样本项目(研究“要素”的xcode docs) 根据要求,它不使用刀具;它以硬的方式制定了一切。 它有好的例子,使用塔巴主计长和航海主计长,并多或少以建议的方式将责任分给维也纳国际中心。