iphone - When do you need to use a view controller? -


I am diving into iPhone development and am trying to see my head around one of my original ideas If you see an example of GL Paint on Apple Dev site, you will see a project that <...

  1. an app representative class
  2. a uiwindow subclass < / Li>
  3. and a uiview subclass

and the uiview subclass applies all core graphics painting logic and possible to touch events The Creeper. My questions are ...

  1. Why is no visual controller implemented to handle that visual argument?
  2. Can you use a visual controller to implement that logic, or to implement it in the UIV sub-class?
  3. And finally, when you should use a visual controller to apply visual logic code?

Thank you very much for your help!

One view knows how to interact with the user. It knows how to display some data, how to manage events, and how to give feedback to the user.

A visual controller knows what, but now how. It knows what data is displayed, and what to do in response to user action.

A UIButan knows how to display a title and image, and how to track a click, but the title should not be clicked once. UITableView knows how to display data in cells and how to succeed, but it does not know which data is displayed or what to do if the cell is removed. For this, it uses a representative and data source, which is often a visual controller.

What this division makes and how easy it is to design and maintain you can create sub-squares of tableviews for each type of table argument, but then you can not control other scenes. A visual controller can control many ideas and coordinate between them.

Edit:

So you should use a view controller at any time:

  • Coordinate between multiple views.
  • Coordination between model data and views
  • Answer a user interaction with a view.
  • Load and reload ideas. Note that a view controller is not strictly a UIViewController. You may have a view controller that is owned by UIViewController and handles some views, but this is NSObject or Joe Also, the view controller manages some portion of the view hierarchy contained in the UIViewController and that the UIViewController is owned by UIViewController may alternately be part of the hierarchy contained on an application rep and a The Avigeshn may be owned by tabs or other meta controller.

    Then the application representative is the owner of zero or more meta controllers such as UINavigationController. Each Meta Controller has one or more UIViewControllers, each of them has a visual hierarchy and has several simple view controllers Help in managing parts of the hierarchy. If there is no need for the Meta Controller, then the application representative may be self or UIViewController.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -