extracting reusable UI parts in cocoa touch - views vs controllers - how should it be done?
Let's say I am designing an iPad app that presents user a screen. The screen contains several "controls" that for the sake of this example can be simple labels with +/- signs that increment/decrement integer value presented by the label, making sure that the value doesnt exceed max number defined for each control (numerical up/down control, but could be anything that has some simple logic). As integers are manipulated some read only values are calculated (labels). Moreover each "control" should respond to a tap gesture (and for example increase value by 10) The question i want to ask is - how should I design such a screen in terms of MVC used in cocoa touch? Given that the view controller that manages the screen is called MainController:
- Should numeric up/down controls be separate views containing all the logic (somehow violates MVC pattern) that are added to MainController.view?
- Should numeric up/down controls be separate viewCo开发者_如何学运维ntrollers (with a view attached to them of course) containing all the logic (more reasonable approach in terms of MVC - am I correct?)
- Are touches/gestures processed on viewcontroller or view level?
- Up/Down controls should be filled with function through the screen's View-Controller (MainController)
- There is no need for extra View-Controllers on that control-level -- in fact, Apple suggests that for such commom situations only one View-Controller exists (MainController)
- Touches/Guestures are processed on View-Controller level (MainController)
精彩评论