-1

I want to display data into table view cell , how I can achive this. Please help me

-(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;
}

Please Help me.

4

4 に答える 4

1

私はあなたが新しいiPhone開発者だと思います..あなたのコードには多くのエラー/バグがあります...

私はあなたが欲しいと思います

「カスタマイズセルの作成方法」`このリンクを参照してください....参考にしてください

于 2012-04-25T13:30:17.360 に答える
0

次を使用できます。

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

カスタムUITableViewCellクラスを作成したくない場合。

于 2012-04-25T15:34:11.787 に答える
0

これを読む以外に:http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7

を使用してアクセスする代わりに、IBOutlets を設定して、インターフェイス ビルダー/ストーリーボードがどのように役立つかを調べてみてください[cell viewWithTag:3]。IBOutlets を使用すると、次のように名前で参照できます。

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

さて、あなたがよりよく読んだ日付についてNSDate、そしてNSDateFormatter:)

于 2012-04-25T13:46:26.440 に答える
0

あなたはこのようなものを探していますか:

- (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 を設定し、ストーリーボードのセルに関連付ける必要があります。次に、データをラベルに挿入できるように、カスタム セルに必要な 3 つのラベル (title、postedBy、onDate) を設定する必要があります。

このチュートリアルが役立つかもしれません: http://ijoshsmith.com/2011/07/16/creating-a-custom-uitableviewcell-in-ios-4/

于 2012-04-25T14:33:20.093 に答える