0
嗨,大家好,我無法將圖像文件製作爲我製作的自定義uitableview單元格。圖像太小,我不知道如何放大。 Thnx提前尋求幫助。無法獲取UIImage以適應自定義UITableViewCell
#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,但我無法訪問imageView形式我的自定義類是奇怪的。我設置屬性和合成它,但是當我試圖self.imageView它不認爲它是關鍵詞 –
那麼'UITableViewCell'已經有一個'imageView'屬性,所以你應該一定能夠訪問它,但它看起來像你的'UIImageView'是'imgView'。您可以不使用內置的'imageView'並使用您的'imgView'來代替。 –
但是在你的UITableViewController中,當你在做'cell.imageView'時,通過'cell.imgView'來訪問你要添加到自定義單元格中的那個。 –