UITableView Class Reference

来源:互联网 发布:美工电脑固态 编辑:程序博客网 时间:2024/05/16 23:50

deleteSections:withRowAnimation:

Deletes one or more sections in thereceiver, with an option to animate the deletion.

删除一个或多个分区,可以选择伴随着删除的动画。

- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

参数:

sections

An index set that specifies the sectionsto delete from the receiving table view. If a section exists after thespecified index location, it is moved up one index location.

animation

YES toanimate the deletion of sections, otherwise NO.

讨论:

Note the behavior of this method when itis called in an animation block defined by the lbeginUpdatesand endUpdatesmethods. UITableViewdefers any insertions of rows or sections until after it has handled thedeletions of rows or sections. This happens regardless of ordering of theinsertion and deletion method calls. This is unlike inserting or removing anitem in a mutable array, where the operation can affect the array index usedfor the successive insertion or removal operation. For more on this subject,see “Batch Insertion andDeletion of Rows and Sections” in Table View ProgrammingGuide for iPhone OS.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– insertSections:withRowAnimation:

– reloadSections:withRowAnimation:

相关的例子代码:

BonjourWeb

CoreDataBooks

iPhoneCoreDataRecipes

声明于:

UITableView.h

 

dequeueReusableCellWithIdentifier:

Returns a reusable table-view cell objectlocated by its identifier.

- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier

参数:

identifier

A string identifying the cell object tobe reused. By default, a reusable cell’sidentifier is its class name, but you can change it to any arbitrary value.

返回值:

A UITableViewCellobject with the associated identifier or nilif no such object exists in the reusable-cell queue.

讨论:

For performance reasons, a table view’sdata source should generally reuse UITableViewCellobjects when it assigns cells to rows in its tableView:cellForRowAtIndexPath:method. A table view maintains a queue or list of UITableViewCellobjects that the table view’s delegate has marked for reuse. It marksa cell for reuse by assigning it a reuse identifier when it creates it (thatis, in the initWithFrame:reuseIdentifier:method of UITableViewCell). Thedata source can access specific “template”cell objects in this queue by invoking the dequeueReusableCellWithIdentifier:method. You can access a cell’s reuse identifier through its reuseIdentifierproperty, which is defined by UITableViewCell.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

相关的例子代码:

BatteryStatus

DrillDownSave

iPhoneCoreDataRecipes

TableViewSuite

UICatalog

声明于:

UITableView.h

 

deselectRowAtIndexPath:animated:

Deselects a given row identified by indexpath, with an option to animate the deselection.

- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated

参数:

indexPath

An index path identifying a row in thereceiver.

animated

YES ifyou want to animate the deselection and NOif the change should be immediate.

讨论:

Calling this method does not cause thedelegate to receive a tableView:willSelectRowAtIndexPath:or tableView:didSelectRowAtIndexPath:message, nor will it send UITableViewSelectionDidChangeNotificationnotifications to observers.

Calling this method does not cause anyscrolling to the deselected row.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– indexPathForSelectedRow

相关的例子代码:

AddMusic

iPhoneCoreDataRecipes

TableViewSuite

TheElements

TouchCells

声明于:

UITableView.h

 

endUpdates

Conclude a series of method calls thatinsert, delete, select, or reload rows and sections of the receiver.

- (void)endUpdates

讨论:

You call this method to bracket a seriesof method calls that began with beginUpdatesand that consist of operations to insert, delete, select, and reload rows andsections of the table view. When you call endUpdates,UITableView animates the operations simultaneously.Invocations of beginUpdates and endUpdates cannot be nested. If you do not makethe insertion, deletion, and selection calls inside this block, table attributessuch as row count might become invalid.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

声明于:

UITableView.h

 

indexPathForCell:

Returns an index path representing therow and section of a given table-view cell.

返回指定单元格在

- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell

参数:

cell

A cell object of the table view.

返回值:

An index path representing the row andsection of the cell or nil ifthe index path is invalid.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– cellForRowAtIndexPath:

声明于:

UITableView.h

 

indexPathForRowAtPoint:

Returns an index path identifying the rowand section at the given point.

- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point

参数:

point

A point in the local coordinate system ofthe receiver (the table view’s bounds).

返回值:

An index path representing the row andsection associated with point or nil ifthe point is out of the bounds of any row.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– indexPathForCell:

声明于:

UITableView.h

 

indexPathForSelectedRow

返回被选中的行或分区的索引路径。

- (NSIndexPath *)indexPathForSelectedRow

返回值:

An index path identifying the row andsection indexes of the selected row or nilif the index path is invalid.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– selectRowAtIndexPath:animated:scrollPosition:

相关的例子代码:

UICatalog

声明于:

UITableView.h

 

indexPathsForRowsInRect:

An array of index paths each representinga row enclosed by a given rectangle.

- (NSArray *)indexPathsForRowsInRect:(CGRect)rect

参数:

rect

A rectangle defining an area of the tableview in local coordinates.

返回值:

An array of NSIndexPathobjects each representing a row and section index identifying a row withinrect. Returns nil if rect is not valid.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– indexPathForRowAtPoint:

声明于:

UITableView.h

 

indexPathsForVisibleRows

Returns an array of index paths eachidentifying a visible row in the receiver.

- (NSArray *)indexPathsForVisibleRows

返回值:

An array of NSIndexPathobjects each representing a row index and section index that together identifya visible row in the table view. Returns nilif no rows are visible.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– visibleCells

声明于:

UITableView.h

 

initWithFrame:style:

根据给定的框架和样式初始化并返回一个表视图对象。

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style

参数:

frame

A rectangle specifying the initiallocation and size of the table view in its superview’scoordinates. The frame of the table view changes as table cells are added anddeleted.

style

A constant that specifies the style ofthe table view. See “Table View Style”for descriptions of valid constants.

返回值:

Returns an initialized UITableView object or nilif the object could not be successfully initialized.

讨论:

You must specify the style of a tableview when you create it and you cannot thereafter modify the style. If youinitialize the table view with the UIViewmethod initWithFrame:,the UITableViewStylePlainstyle is used as a default.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

相关的例子代码:

Reachability

TheElements

声明于:

UITableView.h

 

insertRowsAtIndexPaths:withRowAnimation:

Inserts rows in the receiver at thelocations identified by an array of index paths, with an option to animate theinsertion.

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

参数:

indexPaths

An array of NSIndexPathobjects each representing a row index and section index that together identifya row in the table view.

animation

A constant that either specifies the kindof animation to perform when inserting the cell or requests no animation. See “Table Cell Insertionand Deletion Animation” for descriptions of theconstants.

讨论:

UITableView callsthe relevant delegate and data source methods immediately afterwards to get thecells and other content for visible cells.

Note the behavior of this method when itis called in an animation block defined by the lbeginUpdatesand endUpdatesmethods. UITableViewdefers any insertions of rows or sections until after it has handled thedeletions of rows or sections. This happens regardless of ordering of theinsertion and deletion method calls. This is unlike inserting or removing anitem in a mutable array, where the operation can affect the array index usedfor the successive insertion or removal operation. For more on this subject,see “Batch Insertion andDeletion of Rows and Sections” in Table View ProgrammingGuide for iPhone OS.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– insertSections:withRowAnimation:

– deleteRowsAtIndexPaths:withRowAnimation:

– reloadRowsAtIndexPaths:withRowAnimation:

相关的例子代码:

iPhoneCoreDataRecipes

TaggedLocations

声明于:

UITableView.h

 

insertSections:withRowAnimation:

Inserts one or more sections in thereceiver, with an option to animate the insertion.

插入一个或多个分区,可以选择是否伴随着动画。

- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

参数:

sections

An index set that specifies the sectionsto insert in the receiving table view. If a section already exists at thespecified index location, it is moved down one index location.

animation

A constant that indicates how theinsertion is to be animated, for example, fade in or slide in from the left.See “Table Cell Insertionand Deletion Animation” for descriptions ofthese constants.

讨论:

UITableView callsthe relevant delegate and data source methods immediately afterwards to get thecells and other content for visible cells.

Note the behavior of this method when itis called in an animation block defined by the lbeginUpdatesand endUpdatesmethods. UITableViewdefers any insertions of rows or sections until after it has handled thedeletions of rows or sections. This happens regardless of ordering of theinsertion and deletion method calls. This is unlike inserting or removing anitem in a mutable array, where the operation can affect the array index usedfor the successive insertion or removal operation. For more on this subject,see “Batch Insertion andDeletion of Rows and Sections” in Table View ProgrammingGuide for iPhone OS.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– insertRowsAtIndexPaths:withRowAnimation:

– deleteSections:withRowAnimation:

– reloadSections:withRowAnimation:

相关的例子代码:

iPhoneCoreDataRecipes

声明于:

UITableView.h

 

numberOfRowsInSection:

返回特定分区的行数(表单元格的个数)。

- (NSInteger)numberOfRowsInSection:(NSInteger)section

参数:

section

An index number that identifies a sectionof the table. Table views in a plain style have a section index of zero.

返回值:

An index number that identifies a row inthe given section.

讨论:

UITableView getsthe value returned by this method from its data source and caches it.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– numberOfSections

声明于:

UITableView.h

 

numberOfSections

Returns the number of sections for thereceiver.

返回消息接收者中的分区的个数。

- (NSInteger)numberOfSections

返回值:

The number of sections in the table view.

表视图中分区的个数。

讨论:

UITableView getsthe value returned by this method from its data source and caches it.

UITableView通过这个方法从它的数据源获取值并且将值放入缓存。

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– numberOfRowsInSection:

声明于:

UITableView.h

 

rectForFooterInSection:

Returns the drawing area for the footerof the specified section.

- (CGRect)rectForFooterInSection:(NSInteger)section

参数:

section

An index number identifying a section ofthe table view. Plain-style table views always have a section index of zero.

返回值:

A rectangle defining the area in whichthe table view draws the section footer.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

声明于:

UITableView.h

 

rectForHeaderInSection:

Returns the drawing area for the headerof the specified section.

- (CGRect)rectForHeaderInSection:(NSInteger)section

参数:

section

An index number identifying a section ofthe table view. Plain-style table views always have a section index of zero.

返回值:

A rectangle defining the area in whichthe table view draws the section header.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

声明于:

UITableView.h

 

rectForRowAtIndexPath:

Returns the drawing area for a rowidentified by index path.

- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

参数:

indexPath

An index path object that identifies arow by its index and its section index.

返回值:

A rectangle defining the area in whichthe table view draws the row or CGRectZeroif indexPath is invalid.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

声明于:

UITableView.h

 

rectForSection:

Returns the drawing area for a specifiedsection of the receiver.

- (CGRect)rectForSection:(NSInteger)section

参数:

section

An index number identifying a section ofthe table view. Plain-style table views always have a section index of zero.

返回值:

A rectangle defining the area in whichthe table view draws the section.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

声明于:

UITableView.h

 

reloadData

Reloads the rows and sections of thereceiver.

重新加载表的行和分区。

- (void)reloadData

讨论:

Call this method to reload all the datathat is used to construct the table, including cells, section headers andfooters, index arrays, and so on. For efficiency, the table view redisplaysonly those rows that are visible. It adjusts offsets if the table shrinks as aresult of the reload. The table view’s delegate or data sourcecalls this method when it wants the table view to completely reload its data.It should not be called in the methods that insert or delete rows, especiallywithin an animation block implemented with calls to beginUpdatesand endUpdates

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

相关的例子代码:

CryptoExercise

Reachability

XMLPerformance

声明于:

UITableView.h

 

reloadRowsAtIndexPaths:withRowAnimation:

Reloads the specified rows using acertain animation effect.

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPathswithRowAnimation:(UITableViewRowAnimation)animation

参数:

indexPaths

An array of NSIndexPathobjects identifying the rows to reload.

animation

A constant that indicates how thereloading is to be animated, for example, fade out or slide out from thebottom. See “Table Cell Insertionand Deletion Animation” for descriptions ofthese constants.

The animation constant affects thedirection in which both the old and the new rows slide. For example, if theanimation constant is UITableViewRowAnimationRight,the old rows slide out to the right and the new cells slide in from the right.

讨论:

Reloading a row causes the table view toask its data source for a new cell for that row. The table animates that newcell in as it animates the old row out. Call this method if you want to alertthe user that the value of a cell is changing. If, however, notifying the useris not important—that is, you just want to change the value that a cell isdisplaying—you can get the cell for a particular row and set its new value.

可用性:

Availablein iPhone OS 3.0b and later.

参见

– insertRowsAtIndexPaths:withRowAnimation:

– deleteRowsAtIndexPaths:withRowAnimation:

相关的例子代码:

BonjourWeb

WiTap

声明于:

UITableView.h

 

reloadSectionIndexTitles

Reloads the items in the index bar alongthe right side of the table view.

- (void)reloadSectionIndexTitles

讨论:

This method gives you a way to update thesection index after inserting or deleting sections without having to reload thewhole table.

可用性:

Availablein iPhone OS 3.0b and later.

参见

– sectionIndexTitlesForTableView:(UITableViewDataSource)

声明于:

UITableView.h

 

reloadSections:withRowAnimation:

Reloads the specified sections using agiven animation effect.

- (void)reloadSections:(NSIndexSet *)sectionswithRowAnimation:(UITableViewRowAnimation)animation

参数:

sections

An index set identifying the sections toreload.

animation

A constant that indicates how thereloading is to be animated, for example, fade out or slide out from the bottom.See “Table Cell Insertionand Deletion Animation” for descriptions ofthese constants.

The animation constant affects thedirection in which both the old and the new section rows slide. For example, ifthe animation constant is UITableViewRowAnimationRight,the old rows slide out to the right and the new cells slide in from the right.

讨论:

Calling this method causes the table viewto ask its data source for new cells for the specified sections. The table viewanimates the insertion of new cells in as it animates the old cells out. Callthis method if you want to alert the user that the values of the designatedsections are changing. If, however, you just want to change values in cells ofthe specified sections without alerting the user, you can get those cells anddirectly set their new values.

可用性:

Availablein iPhone OS 3.0b and later.

参见

– insertSections:withRowAnimation:

– deleteSections:withRowAnimation:

相关的例子代码:

iPhoneCoreDataRecipes

声明于:

UITableView.h

 

scrollToNearestSelectedRowAtScrollPosition:animated:

Scrolls the row nearest to a specifiedposition in the table view to that position.

- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

参数:

scrollPosition

A constant that identifies a relativeposition in the receiving table view (top, middle, bottom) for the row whenscrolling concludes. See “Table View ScrollPosition” a descriptions of valid constants.

animated

YES ifyou want to animate the change in position, NOif it should be immediate.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– scrollToRowAtIndexPath:atScrollPosition:animated:

声明于:

UITableView.h

 

scrollToRowAtIndexPath:atScrollPosition:animated:

Scrolls the receiver until a rowidentified by index path is at a particular location on the screen.

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

参数:

indexPath

An index path that identifies a row inthe table view by its row index and its section index.

scrollPosition

A constant that identifies a relativeposition in the receiving table view (top, middle, bottom) for row whenscrolling concludes. See “Table View ScrollPosition” a descriptions of valid constants.

animated

YES ifyou want to animate the change in position, NOif it should be immediate.

讨论:

Invoking this method does not cause thedelegate to receive a scrollViewDidScroll:message, as is normal for programmatically-invoked user interface operations.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– scrollToNearestSelectedRowAtScrollPosition:animated:

声明于:

UITableView.h

 

selectRowAtIndexPath:animated:scrollPosition:

Selects a row in the receiver identifiedby index path, optionally scrolling the row to a location in the receiver.

- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition

参数:

indexPath

An index path identifying a row in thereceiver.

animated

YES if youwant to animate the selection and any change in position, NO if the change should be immediate.

scrollPosition

A constant that identifies a relativeposition in the receiving table view (top, middle, bottom) for the row whenscrolling concludes. See “Table View ScrollPosition” a descriptions of valid constants.

讨论:

Calling this method does not cause thedelegate to receive a tableView:willSelectRowAtIndexPath:or tableView:didSelectRowAtIndexPath:message, nor will it send UITableViewSelectionDidChangeNotificationnotifications to observers.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– indexPathForSelectedRow

声明于:

UITableView.h

 

setEditing:animated:

Toggles the receiver into and out ofediting mode.

- (void)setEditing:(BOOL)editinganimated:(BOOL)animate

参数:

editing

YES to enterediting mode, NO to leave it. The default value is NO .

animate

YES toanimate the transition to editing mode, NOto make the transition immediate.

讨论:

When you call this method with the valueof editing set to YES, thetable view goes into editing mode by calling setEditing:animated:on each visible UITableViewCellobject. Calling this method with editing set to NOturns off editing mode. In editing mode, the cells of the table might show aninsertion or deletion control on the left side of each cell and a reorderingcontrol on the right side, depending on how the cell is configured. (See UITableViewCell ClassReference for details.) The data source of thetable view can selectively exclude cells from editing mode by implementing tableView:canEditRowAtIndexPath:.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

  @property editing

声明于:

UITableView.h

 

visibleCells

Returns the table cells that are visiblein the receiver.

- (NSArray *)visibleCells

返回值:

An array containing UITableViewCellobjects, each representing a visible cell in the receiving table view.

可用性:

能够在iPhoneOS 2.0及之后的版本中使用。

参见

– indexPathsForVisibleRows

相关的例子代码:

TableViewSuite

声明于:

UITableView.h

原创粉丝点击