2011-06-28 9 views
0

私は画像のようなビューを持つアプリケーションを開発しています。 私はテーブルビューを持っています。 私の問題は、チャットボックスのセルを元のTable viewcellフレームにいくつか表示する方法です。白いボックスのようTableViewセルフレームの問題

 は、元のテーブルビューのセルにいくつかの権利である

コード: - あなたがcellForRowAtIndexPathメソッドでセル内にあるビューの枠を設定する必要が

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

    static NSString *CellIdentifier = @"Cell"; 
    int row = [indexPath section]; 

    UITableViewCell *startCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(10, 0, 200, 50) reuseIdentifier:CellIdentifier] autorelease]; 
    UITableViewCell *durationCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(50, 0, 200, 100) reuseIdentifier:CellIdentifier] autorelease]; 
    UITableViewCell *radiusCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(100, 0, 200, 150) reuseIdentifier:CellIdentifier] autorelease]; 

    startCell.textLabel.text = @"Start:"; 
    durationCell.textLabel.text = @"Duration:"; 
    radiusCell.textLabel.text = @"radius"; 


    if (row == 0) 
    { 
     return startCell; 
    } 
    else if (row == 1) 
    { 
     return durationCell; 
    } 

    return radiusCell; 


} 
+0

セルにimageViewが含まれていますか? – Maulik

+0

@maulikいいえ何も入っていません。 – Gypsa

+0

switch(indexPath.row)のようなスイッチケースの使用を試みます。 – Maulik

答えて

1

セルにUIImageViewが含まれている場合、カスタムセルを作成する必要があります。カスタムセルの.mファイルで、そのメソッドにというメソッドを作成する必要があります。

`CGRectMake frame= CGRectMake(5, 12, 19, 15);  
    myImageView.frame = frame;` 
1

かのことができますカスタムセルを作成し、いつでもどこにでも配置することができます。