开发者

What is the difference between a View and a View Controller? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened开发者_Python百科, visit the help center. Closed 9 years ago.

from an iphone development perspective


A view is an object that is drawn to the screen. It may also contain other views (subviews) that are inside it and move with it. Views can get touch events and tell listeners or delegates about any events that occur in them. Views are dumb, and do not know about the structure of your application, and are simply told to display themselves in some state, and listened to for events.

For example: a text label, a button, a checkbox, a progress bar.


A view controller is not drawable to the screen directly, it manages a group of view objects. View controllers usually have a single view with many subviews. The view controller manages the state of these views. A view controller is smart, and it knows how to interact with your application. It tells the dumb view objects what to do and how to show themselves.

For example: a screen that shows a list of users, an edit user form, a login screen.


A view controller is the glue between your overall application and the screen. It controls the views that it owns according to the logic of your application.


The controller connects views (UI elements) to model objects. Views are for display, model objects are for data, controllers are the glue in between them.

See the Cocoa Fundamentals Guide for an explanation of the three tier architecture of the Model-View-Controller pattern.


I just got started with my first apps. Very simply put view is the visual aspect of the app

and view controller is the code that actually controls or manipulates the visual aspect.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜