Ive been on this problem for a few weeks now.
Basically when i scroll up/down within a TableView thar uses a Custom Cell designed in IB all the content gets mixed up and misplaced
Ive tried multiple solutions but to no avail, your gonna have to excuse my code a little bit.
People keep suggesting to make a subView for the table cell but i have no idea how to do that =/ still quite new to iOS development so if you have a possible answer, can you detail it as much as possible please.
Once again, sorry for my code =/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyIdentifier];
NSInteger intCellTag;
NSDictionary *dictionary = [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
[[[NSBundle mainBundle] loadNibNamed:@"EventsCustomTVCell" owner:self options:nil] lastObject];
cell = tvCell;
self.tvCell = nil;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.tag = intCellTag;
intCellTag++;
UIImage *customCellBG = [UIImage imageNamed:@"EventsCustomTableCellBG.png"];
UIImageView *customCellBGImageView = [[UIImageView alloc] initWithImage: customCellBG];
customCellBGImageView.contentMode = UIViewContentModeScaleToFill;
cell.backgroundView = customCellBGImageView;
[customCellBGImageView release];
[cell.contentView addSubview:imgThumbnail];
[cell.contentView addSubview:lblName];
[cell.contentView addSubview:lblDescription];
[cell.contentView addSubview:lblDate];
}
imgThumbnail.image = [UIImage imageNamed:[dictionary objectForKey: @"Thumbnail"]];
lblName.text = [dictionary objectForKey:@"Title"];
lblDescription.text = [dictionary objectForKey:@"Description"];
lblDate.text = [dictionary objectForKey:@"Date"];
return cell;
}