我不熟悉您正在使用,在我的情況,我需要創建tableview中類外的自定義表格視圖單元格類的方法名,
類被稱爲QRTYPECELL和以下是相關代碼:
@implementation QRTypeCell
@synthesize imageView;
@synthesize labelview;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
imageView = nil;
labelview= nil;
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,30,30)];
imageView.contentMode = UIViewContentModeCenter;
[self.contentView addSubview:imageView];
self.contentView.backgroundColor = [UIColor blackColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.textColor = [UIColor greenColor];
label.backgroundColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:17];
self.labelview = label;
[self.contentView addSubview:label];
}
return self;}
然後在TableView中類:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
QRTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[QRTypeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];}
CurrentQRCode = (QRCode *)[fetchedResultsController objectAtIndexPath:indexPath];
NSString *icon = CurrentQRCode.parsed_icon;
NSString *string = CurrentQRCode.parsed_string;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
NSString *filePath = [[NSBundle mainBundle] pathForResource:icon ofType:@"png"];
UIImage *image_file = [UIImage imageWithContentsOfFile:filePath];
什麼是'returnCellForEach替換此行
:'和你在哪裏打電話呢? – jrturton 2012-03-06 06:54:18
@jrturton:這是我的自定義方法。我爲自定義單元格創建了它。 – Kiran 2012-03-06 07:01:23
_你從哪裏叫它?你的cellForRowAtIndexPath方法在哪裏? – jrturton 2012-03-06 07:14:22