views:

40

answers:

1

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 viewControllers (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?
A: 
  • 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)
Till
thanks for your answer! So does it mean that if I want to have like 5 up/down controls I need to add 10 buttons and 10 outlets and 10 IBActions to viewcontroller?Thats seems as an anti pattern but maybe I am overlooking something :) Or maybe should I extract up/down controls to a view? (If yes can i design the view itself in Iterface Builder)
adrin
Dave
Very similar discussion: http://stackoverflow.com/questions/1264296/iphone-subview-design-uiview-vs-uiviewcontroller
Dave