0

こんにちは、画像ファイルを作成したカスタム uitableview セルにすることができません。画像が小さすぎて拡大の仕方がわかりません。事前に助けてください。

#import <UIKit/UIKit.h>

@interface customCell : UITableViewCell
{
  //UILabel *frontLabel;    
}
@property(nonatomic , strong) IBOutlet UILabel *label;
@property(nonatomic , strong) IBOutlet UILabel *label2;
@property(nonatomic , strong) IBOutlet UIImageView *imgView;
@end

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *CellIdentifier = @"cell";

  customCell * cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
    cell = [[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  }


  User * user = [self.list objectAtIndex: indexPath.row];

  cell.label.text = user.username;
  NSString *url = user.profilePic;
  UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
  cell.imageView.contentMode =UIViewContentModeScaleAspectFit;
  cell.imageView.image =image;

  return cell;
}
4

1 に答える 1

1

クラス (すべてのcustomCellクラスは大文字で始まり、プロパティと変数は小文字で始まる必要があります) では、オブジェクトのframeプロパティをimageView適切なサイズと位置に設定するだけです。

imageView.frame = CGRectMake(10., 10., 50., 50.)最初の 2 つのパラメーターが画像ビューの右上隅の x と y の位置で、次の 2 つのパラメーターが幅と高さのようなものです。

または、これらのプロパティが IBOutlet として指定されているため、レイアウトに XIB ファイルを使用している場合は、サイズの設定が既にそこにあるはずです。

XIB の Interface Builder のスクリーンショットや の実装コードを見ることなくcustomCell、それが私ができる最善の方法です。

于 2012-05-26T02:06:26.753 に答える