Objective c 如何将数据显示到表视图单元格中

Objective c 如何将数据显示到表视图单元格中,objective-c,ios,cocoa-touch,Objective C,Ios,Cocoa Touch,我想将数据显示到表视图单元格中,我如何实现这一点。请帮帮我 -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *feedsTableIdentifier = @"FeedsTableIdentifier"; UITableViewCell *cell = [tableView dequeu

我想将数据显示到表视图单元格中,我如何实现这一点。请帮帮我

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *feedsTableIdentifier = @"FeedsTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:feedsTableIdentifier];
    if (cell==nil) {
        [[NSBundle mainBundle] loadNibNamed:@"FeedsTableViewCell" owner:self options:nil];
        cell=tableViewCell;
        self.tableViewCell=nil;
    }
    title=(UILabel *)[cell viewWithTag:1];
    title.text=[NSString stringWithFormat:@"%d",indexPath.row];

    postedBy=(UILabel*)[cell viewWithTag:2];
    postedBy.text=[NSString stringWithFormat:@"%d",indexPath.row];

    onDate = (UILabel *)[cell viewWithTag:3];
    onDate.text=[NSString stringWithFormat:@"%d",indexPath.row];

    return cell;
}

请帮帮我。

我想你是新的Iphone开发者。。在您的代码中有许多错误/Bug

我想你想要

除了阅读以下内容:

尝试研究interface builder/storyboard如何帮助您,设置IBoutlet,而不是尝试使用
[cell viewWithTag:3]
访问它们。使用IBOutlets,您只需按名称引用它们,如:

postedByLabel.text = @"Some user";
titleLabel.text = @"A title!";

现在,对于日期,您最好阅读有关
NSDate
NSDateFormatter
:)

您是否正在寻找类似的内容:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    CellController *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
    cell = [[CellController alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.menuLabel.text = [self.homeList objectAtIndex:indexPath.row];

    // Configure the cell...

    return cell;
}
您需要有一个自定义的CellController设置,并与故事板中的单元格相关联。然后需要在自定义单元格中设置所需的三个标签(title、postedBy、onDate),以便将数据插入标签中

本教程可能会对您有所帮助:

您可以使用:

cell.textLabel.text = @"Some text";

如果您不想创建自定义UITableViewCell类。

您所说的显示数据是什么意思?您到底想要什么。。这是您的代码,或者您只需给出示例来显示您想要显示的这类数据我想要设置title、postedby和ondate的值。这些是tableviewcell上的标签