Iphone 如何检查UITableViewCells是否为空

Iphone 如何检查UITableViewCells是否为空,iphone,ios,Iphone,Ios,我正在使用indexpathforvisiblerows,它给出uitableview中可见行的IndExpath。如何检查返回的索引路径中的空白单元格?./p> `NSArray*VisiblePath=[self.rootViewController.accountTableView indexPathsForVisibleRows] for(NSIndexPath*VisiblePath中的indexPath) { //getLastCallDate函数 Account*Account=[

我正在使用indexpathforvisiblerows,它给出uitableview中可见行的IndExpath。如何检查返回的索引路径中的空白单元格?./p> `NSArray*VisiblePath=[self.rootViewController.accountTableView indexPathsForVisibleRows]

for(NSIndexPath*VisiblePath中的indexPath) {

//getLastCallDate函数

Account*Account=[self.fetchedResultsController对象索引路径:indexPath]; NSString*lastCallDate

if ([[account Calls] count] > 0) {
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd"];

    Call *call = [[account Calls] objectAtIndex:0];

     lastCallDate = [NSString stringWithFormat:@"Last Call Date: %@",[dateFormatter stringFromDate:call.date]];

    //NSLog(@"detail - %@", cell.detailTextLabel.text);
    [dateFormatter release];
    return lastCallDate;
}
else
    lastCallDate =@"";
return lastCallDate;
`
在搜索获取的结果时,控制器的值不会像导致数组绑定执行选项的可见行那么多。我假设您有一个没有节头的普通UITableView,只有行。然后,显示上显示的行数
tableView.frame.size.height/tableView.rowHeight
。减去该数字可见行的数目

使用上述算法,我得到了总共16行可见单元格5


现在由您来计算
16-5

我假设您有一个没有节头的普通UITableView,只有行。然后显示的行数
tableView.frame.size.height/tableView.rowHeight
。减去可见行数

使用上述算法,我得到了总共16行可见单元格5


现在,您可以在调用
getLastCallDate:
之前计算
16-5
,检查
indexPath.row
是否小于数据源中的项数。类似于-

for (NSIndexPath *indexPath in visiblePaths) 
{
     if(indexPath.row < [self.items count]) //items is your data source array
     {
          //your code
     }
}
for(可访问路径中的nsindepath*indepath)
{
如果(indexath.row<[self.items count])//items是您的数据源数组
{
//你的代码
}
}

在调用
getLastCallDate:
之前,请检查
indepath.row
是否小于数据源中的项数。例如-

for (NSIndexPath *indexPath in visiblePaths) 
{
     if(indexPath.row < [self.items count]) //items is your data source array
     {
          //your code
     }
}
for(可访问路径中的nsindepath*indepath)
{
如果(indexath.row<[self.items count])//items是您的数据源数组
{
//你的代码
}
}

否我有几个有数据的TableCell,其余为空。我要有数据的单元格的计数否我有几个有数据的TableCell,其余为空。我要有数据的单元格的计数