开发者

Custom view controller help

I'm a bit confused as to implementing custom view controllers. I have a view that I want to have slide down from the top of the window. The view has three buttons on it. When the button for the view to drop is tapped the view drops. And when tapped again the view slides up/goes 开发者_高级运维away. I have the drop down view saved as a nib file. Would this be the best method for implementation? Or should I have the view in the main view's nib? And could I get some direction on how I should set it up?


The usual pattern has each of the view's stored in their own XIB file and associated with their own view controller objects. You then alloc/init the new view controller and point it to its XIB and present it modally. Once its presented, its VC responds to its actions and interacts with the model and updates its own views. You can then dismiss that view controller and its views to revert back to the parent view controller.

I have noticed a pattern mentioned in SO where people alloc/init a child VC and then within their present VC they addSubview the newVC.view, but that just seems pretty unusual to me.

If you just have a subview that is being animated down to partially cover the screen, perhaps it doesn't warrant its own VC since, as I think I'm understating your usage, its actions would map to your current VC. In that case, I would either create its contents programmatically or just as another view in the XIB for your first VC and animate that down when needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜