1

UIImageViewカスタマイズしてUITableViewCellサイズを変更したいので、表示モードを左に設定します。サイズを変更するには、以下のコードを適用しています。

[cell.IBImage setFrame:CGRectMake(201,12,50,20)];

画像の幅が 100 で、50 に縮小したいのですが、それでも幅 100 で表示されます。表示モードを設定すると正常に動作しますScale To Fillが、表示モードをLEFTにしたいです。

完全なメソッド cellForRowAtIndexPath は以下のとおりです。

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

static NSString *CellIdentifier = @"DetailCell";

DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"DetailCell" owner:self options:nil];

cell = (DetailCell *)[topLevelObjects objectAtIndex:0];

clsDetailResponse *Response = [self.Histories objectAtIndex:[indexPath row]];

[cell.IBUsernameLabel setText:[NSString stringWithFormat:@"%@ %@", Response.Firstname, Response.Lastname]];

[cell.IBImage setFrame:CGRectMake(201, 12, 50, 20)];

return cell;
}
4

3 に答える 3

1

画像ではなくimageViewフレームのサイズを変更しているので、必要に応じて画像をトリミングできます。

UIImage *ima = cell.image.image;
CGRect cropRect = CGRectMake(0, 0, 50,20);
CGImageRef imageRef = CGImageCreateWithImageInRect([ima CGImage], cropRect);
[cell.image setImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);
cell.image.frame=CGRectMake(10, 10, 50, 20);
于 2012-12-15T13:40:34.693 に答える
0

次の行をファイルの所有者に追加して、フレーム変更に応答する方法を認識していることを確認します。

    [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
    [self setClipsToBounds:YES];
    [self setAutoresizesSubviews:YES];
于 2012-12-15T09:21:33.163 に答える
0

DetailCell クラスに IBImage フレームを設定する

-(void)layoutSubviews:

方法

于 2012-12-15T08:56:46.477 に答える