Can you advise me or send me sample code on how to load a custom bound cell from a .xib please?
I am using this code for a ImagePickerCell.xib in my ImagePickerCell.m
#import "ImagePickerCell.h"
@implementation ImagePickerCell
@synthesize myImageLabel;
@synthesize myImageView;
/*
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
// Initialization code
}
return self;
}*/
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[myImageView release];
myImageView = nil;
[myImageLabel release];
myImageLabel = nil;
[super dealloc];
}
@end
In my table I have this code...
if( indexPath.row == 0)
{
static NSString *CellIdentifier = @"ImagePickerCell";
cell = nil;
ImagePickerCell *cell = (ImagePickerCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ImagePickerCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ImagePickerCell *) currentObject;
break;
}
}
}
UIImage *loadedImage = [UIImage imageNamed:@"noImage.png"];
cell.myImageLabel.text = @"TEST Image name";
cell.myImageView.image = loadedImage;
}else{
Shoe *thisObject = [[mainDelegate shoes] objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.text = thisObject.myName;
cell.detailTextLabel.text = thisObject.designer;
NSString *imageName = thisObject.thumbName;
UIImage *loadedImage = [UIImage imageWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:[@"Documents/" stringByAppendingString:imageName]]];
cell.imageView.image = loadedImage;
}
Thanks so much!