最近在开发iOS7的应用发现有个方法似乎是有问题的,就是下面这个
1
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
下面分别查看之前的实现过程和现在的实现过程
之前的实现过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TeleplayPlayTableCell"; UITableViewCell *cell = [_dataTableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } NSInteger row = [indexPath row];
cell.detailTextLabel.text = @"good"; cell.textLabel.text = [NSString stringWithFormat:@"%d",row]; return cell; }
|
iOS7下面的实现过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TeleplayPlayTableCell"; [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier]; UITableViewCell *cell = [_dataTableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } NSInteger row = [indexPath row];
cell.detailTextLabel.text = @"good"; cell.textLabel.text = [NSString stringWithFormat:@"%d",row]; return cell; }
|
大家可以尝试一下,如果有其他问题,请指教。