i have an awkward problem where calling to [self invalidateModel]; does not redraw my custom cells.
I have a TTTableViewController with an action sheet that allows to order the display of a table when pressed. The data gets redrawn correctly but the cells are not redrawn. Instead there are reused.
To illustrate better :
In my - (void)layoutSubviews { of my CustomTableItemCell class i have this :
if (bookmarked) {
UIImage *bookmark = [UIImage imageNamed: @"bookmarked@2x.png"];
TTImageView *bookmarkView = [[TTImageView alloc] init];
bookmarkView.defaultImage = bookmark;
bookmarkView.frame = CGRectMake(297, 0, 16, 27);
[self.contentView addSubview:bookmarkView];
TT_RELEASE_SAFELY(bookmarkView);
}
Basically if I get a bookmarked item, I want to display a ribbon on the right of my cell. This ribbon gets display correctly.
When I reorder my cell with the action sheet method and call invalidateModel, the first cell which didn’t have any ribon gets putten at a place where was previously a ribbonned item but without redrawing the cell, thus giving a ribon to an item without ribbon.
Code source :
This is my createDatasource function of my TTTableViewController :
- (void)createModel {
self.dataSource = [ServiceRequestDetailedDataSource viewDataSource:self.typeOfAction andOrderBy:orderBy];
// If dataSource nil, show an empty Message
if (self.dataSource == nil) {
[self showEmpty:YES];
}
}
This is my action sheet action of my TTTableViewController that change the orderBy and calls invalidate model :
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
self.orderBy = @"portfolio";
[self invalidateModel];
}
Any tips would be great, I am really stuck here :'(
Found it, just use reuseidentifier. My bad.