Q:UITableView - Cell is nil not called when ReloadData |
Q:表格-细胞是零不叫当reloadData |
I am using Custom Cell class to draw cell's on UITableView. When i first Load the data, cell == nil is called
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] objectAtIndex:1];
}
But second time i reload data the control never goes inside cell == nil.
I tried setting the datasource i.e. dictionary to nil and reload with no success. What i have to do to reload cells from scratch? |
我使用自定义单元格上表格绘制细胞的。当我第一次加载数据时,单元格= = 0
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] objectAtIndex:1];
}
但第二次我重新加载数据时,控件永远不会进入单元格。
我试着设置DataSource即词典为零并重新加载不成功。我必须做什么来从头重新加载细胞? |
answer1: |
回答1: |
Please follow the below steps
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ZACustomCellTableViewCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] lastObject];
}
cell.labelForServiceProviderName.text = [arrayForServiceProvider objectAtIndex:indexPath.row];
return cell;
}
|
请按照以下步骤
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ZACustomCellTableViewCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"ZACustomCellTableViewCell" owner:self options:nil] lastObject];
}
cell.labelForServiceProviderName.text = [arrayForServiceProvider objectAtIndex:indexPath.row];
return cell;
}
|
ios
objective-c
uitableview
|
|