我有 ipad 应用程序,我在其中使用 tableView 显示数据,但问题是它没有在 tableView 中显示数据这里是设置单元格值的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
if (tableView == tableCategory) {
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.textAlignment=UITextAlignmentLeft;
ObjectData*theCellData = [categoryArray objectAtIndex:indexPath.row];
cell.textLabel.text=theCellData.categoryTitle;
return cell;
}
else if (tableView == tableSubCategory)
{
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.textAlignment=UITextAlignmentLeft;
ObjectData*theCellData = [subCategoryArray objectAtIndex:indexPath.row];
NSString *test = theCellData.subCategoryTitle;
NSLog(@"Test Cell is %@",test);
cell.textLabel.text = test;
return cell;
}
else if(tableView == tablePublish)
{
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:16];
cell.textLabel.textAlignment = UITextAlignmentLeft;
GetPublishData *theCellData = [publishArray objectAtIndex:indexPath.row];
NSString *test = [NSString stringWithFormat:@"%@:%@:%@ in:%@:%@",theCellData.UserName,theCellData.ContentTitle,theCellData.ContentType,theCellData.Catgeory,theCellData.SubCategory];
NSLog(@"Test Cell is %@",test);
cell.textLabel.text = test;
cell.detailTextLabel.text = theCellData.ContenAddedTime;
return cell;
}
else
{
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:16];
cell.textLabel.textAlignment = UITextAlignmentLeft;
GetPublishData *theCellData = [publishArray objectAtIndex:indexPath.row];
NSString *test = theCellData.ContentDescription;
cell.textLabel.text = test;
return cell;
}
}
我有 tableView 委托和数据源,但在检查数组中的计数时仍然没有显示任何内容,它显示了其中的项目,但没有在 tableview 中显示数据我为 else 显示的数据表不起作用