0

次の画像のようにカスタマイズされたTableViewがあります

私のTableView

私の考えはtableview4行目にあり、その時間がないので、左を左と同じにimage設定したいのですが、どうすればこれを行うことができますか?label frameimage

4

2 に答える 2

2

ラベルを imageView と同じ左座標に配置する場合は、次のコードを使用できます。

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

    // do the below code after setting the image in your imageView. 

    if (imageView.image == nil) 
    {
        CGRect rectNew = CGRectMake(imageView.frame.origin.x, cell.textLabel.frame.origin.y, cell.textLabel.frame.size.width, cell.textLabel.frame.size.height);
        cell.textLabel.frame = rectNew;
    }
}
于 2012-11-16T07:35:59.447 に答える
1

メソッドでcellForRowAtIndexPath:画像がnilの場合、imageViewのフレームを次のcell.textLable. ように設定します..

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
    if (imageView.image == nil) {
        imageView.hidden = YES;
            cell.textLabel.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y, setWidth, setHight);//set Hight and width of yout textlable of cell
    }
}
于 2012-11-16T07:07:25.120 に答える