UITableView

要让 UITableViewController 实现 UITableViewDataSource 协议,需要实现以下方法:

1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

指定section数

所谓的section,我目前的理解,就是类似通讯录里面的按照首字母分块A、B、C

2. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

指定每个section的row数

3. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

指定对应cell的内容

初始化cell有两种方法:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ToDoEventCell" forIndexPath:indexPath];

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"ToDoEventCell"];
原文地址:https://www.cnblogs.com/mobilefeng/p/4541520.html