난 당신이 내가있는 tableview 클래스 외부에있는 사용자 정의 테이블 뷰 셀 클래스를 만드는 데 필요한 내 경우에 사용하는 방법 이름에 익숙하지 않다 도움이되기를 바랍니다 관련 코드 다음의 TableView 클래스에서
@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;}
: 그리고 IB에
- (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];
와 함께이 라인
을 대체 않았다있어? – jrturton
@jrturton : 이것은 내 사용자 지정 메서드입니다 .i 사용자 지정 셀에 대해 만들었습니다. – Kiran
_ 어디에서 전화하고 있습니까? cellForRowAtIndexPath 메서드는 어디에 있습니까? – jrturton