您的位置:首页 > 其它

overview of the TableView API

2012-04-20 15:03 537 查看
1、Table View

A table view itself is an instance of the UITableView class. This class declares methods that allow you to

configure the appearance of the table view—for example, specifying the default height of rows or providing

a view used as the header for the table. Other methods give you access to the currently selected row as well

as specific rows or cells. You can call other methods of UITableView to manage selections, scroll the table

view, and insert or delete rows and sections.

UITableView inherits from UIScrollView, which defines scrolling behavior for views with content larger

than the size of the window. UITableView redefines the scrolling behavior to allow vertical scrolling only.

一个表视图本身就是UITableView类的实例。该类声明了方法来显示表视图--例如:指定行的高度或提供一个视图作为表头。其他的方法可以访问当前选中的行和特定的行或单元格。你可以调用UITableview的其他方法管理分组,滑动表视图,和插入、删除行和分组。

UITableView 继承了UIScrollView, UIScrollView 为大于窗口大小的视图定义了滑动的行为。 UITableView重新定义了滑动的行为仅允许垂直滑动。

2、Data Source and Delegate 数据源和代理

A UITableView object must have a delegate and a data source. Following the Model-View-Controller design

pattern, the data source mediates between the application’s data model (that is, its model objects) and the

table view; the delegate, on the other hand, manages the appearance and behavior of the table view. The

data source and the delegate are often (but not necessarily) the same object, and that object is frequently

a custom subclass of UITableViewController.(See “Navigating a Data Hierarchy With Table Views” (page

23) for further information.)

一个表视图对象必须有一个代理和一个数据源。依照模型-视图-控制器的设计模式,数据源介于应用的数据模型和表视图之间;另一方面,代理,管理着表视图的外观和行为。

数据源和代理经常(不是必须)是同样的对象,且那个对象经常是UITableViewController的子类

The data source adopts the UITableViewDataSource protocol and the delegate adopts the

UITableViewDelegate protocol. UITableViewDataSource has one optional method through which the

data source tells the table view how many sections it has (the default is one); it also has a required method

through which it tells the table view how many rows are in each section. The UITableViewDelegate

protocol declares a method that the delegate must implement to return a cell object that the table view uses

when drawing a particular row. (“Table View Cells” (page 22) gives more detail about this delegate task.) It

also allows the delegate to modify visible aspects of the table view. Both protocols also include optional

methods for responding to selections and taps on accessory views and for managing the insertion, deletion,

and reordering of cells.

数据源采用了表视图数据源协议,代理采用了表视图代理协议。 表视图数据源有一个可选的方法,通过这个方法,数据源告之表视图有多少分组(部分);表视图还有一个必需的方法,告之在每一个部分(分组)中有多少行 。 表视图代理协议声明了一个方法,代理必须继承返回一个单元格对象

An application can make use of a convenience class, UILocalizedIndexedCollation, to help the data

source organize the data for indexed lists and display the proper section when users tap an item in the index.

The UILocalizedIndexedCollation class also localizes section titles. The

UILocalizedIndexedCollation class was introduced in iOS 3.0.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: