您的位置:首页 > 产品设计 > UI/UE

UITableView——1

2016-07-05 11:10 387 查看
UITableViewController

要实现2个delegate,即UITableViewDataSource,
UITableViewDelegate

UITableViewDataSource       
必须实现的代理

@class UITableView;

@class UINib;

@protocol UITableViewDataSource;

@class UILongPressGestureRecognizer;

@class UITableViewHeaderFooterView;

@class UIRefreshControl;

@class UIVisualEffect;

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;    //节中的行数 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;  //索引路径上的行的单元格

选择实现的代理

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;             
// 如果未实现,默认为1

- (nullable
NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; 
  // 固定字体样式。使用自定义视图(UILabel)如果你想要不同的东西

- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

// 编辑

// 单个行可以选择退出为它们设置的-编辑属性集。如果不执行,所有的行被认为是可编辑的

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;

// Moving/reordering

// 允许排序辅助视图可以显示为一个特定的行。默认情况下,订货控制将只显示如果DataSource工具--党moverowatindexpath:toindexpath

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;

// Index

- (nullable NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView
__TVOS_PROHIBITED;                                                   
// return list of section titles to display in section index view (e.g. "ABCD...Z#")

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
__TVOS_PROHIBITED; 
// tell table which section corresponds to section title/index (e.g. "B",1))

// Data manipulation - insert and delete support

// After a row has the minus or plus button invoked (based on the UITableViewCellEditingStyle for the cell), the dataSource must commit the change

// Not called for edit actions using UITableViewRowAction - the action's handler will be invoked instead

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath
*)indexPath;

// Data manipulation - reorder / moving support

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath
*)destinationIndexPath;

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