I want to update accessoryViews in UITableView, but just on the rows, which the user can a开发者_如何学编程ctually see.
How can I detect which rows are actually on the screen?
Make use of UITableview instance method -visibleCells
visibleCellsReturns the table cells that are visible in the receiver.
- (NSArray *)visibleCellsReturn Value
An array containing
UITableViewCellobjects, each representing a visible cell in the receiving table view.Availability
Available in iOS 2.0 and later.
UITableView has -visibleCells method for that - it returns a NSArray of currently visible cells
Implement this for which row you want not to add accessory.
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
if (row == 0||row == 2)
return nil;
return indexPath;
}
Don't think you really need to detect visible row for updating accessoryViews. You can just implement it in the tableView:cellForRowAtIndexPath: datasource method.
But if you want to get the visible rows you can use
- (NSArray *)visibleCells
加载中,请稍侯......
精彩评论