안녕하세요 여러분, 이미지 파일을 내가 만든 맞춤형 uitableview 셀로 만들 수 없습니다. 이미지가 너무 작아서 그것을 확대하는 방법을 모른다. Thnx 사전에 도움을. 당신의 customCell
클래스에서사용자 정의 UITableViewCell에 맞게 UIImage를 가져올 수 없습니다.
#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;
}
thnx,하지만 난 이상한 이미지 뷰 양식 내 사용자 정의 클래스에 액세스 할 수 없습니다. 나는 속성을 설정하고 synth하지만 그것을 시도했지만 self.imageView로 키 워드로 인식하지 못한다. –
음,'UITableViewCell'에는 이미'imageView' 속성이 있기 때문에 확실히 접근 할 수 있어야한다. 당신의'UIImageView'는'imgView'입니다. 내장 된'imageView'를 사용하지 않고'imgView'를 대신 사용할 수 있습니다. –
또한 UITableViewController에서'cell.imageView'를 할 때'cell.imgView'를 사용하여 사용자 정의 셀에 추가 할 수 있습니다. –