This started to happen out of the blue. Any ideas: Code:
CUSTOMCLASSNAME (I have replaced the actual class name as it contains the name of the client.)
Initialising my tableView:
[self.tableView registerClass:[CUSTOMCLASSNAME class] forCellReuseIdentifier:[self reuseIdentifier]];
In cell for row:
Hi, the title is being printed in the console. This is my cellForRow:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AVTCheckListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self reuseIdentifier] forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(AVTCheckListTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
ChecklistGroup *group = [self.checklistFetchedResultsController.fetchedObjects objectAtIndex:indexPath.section];
ChecklistItem *item = [self getChecklistItemForIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[[cell cellTextView] setAttributedText:[[item checked] boolValue] ? [[NSAttributedString alloc] initWithString:[item name] attributes:@{ NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle) } ] : [[NSAttributedString alloc] initWithString:[item name]]];
[[cell cellTextView] setUserInteractionEnabled:[[group isUserDefined] boolValue]];
[[cell cellTextView] setTag:indexPath.row];
[[cell cellTextView] setDelegate:self];
[[cell tickImage] setHidden:![[item checked] boolValue]];
}
//Method that returns re-use:
- (NSString *) reuseIdentifier {
return @"CheckListTableView";
}
Return [cell contentView]
instead of cell
from tableView:viewForHeaderInSection:
EDIT: This somehow led to crashes on long-press gestures on UI Buttons. To fix that, I gave up and used another section with a single item as a fake section header.
I found this warning during my viewForHeaderInSection
implementation.
This is my solution in Swift 2.x:
let headerView = self.tableView.dequeueReusableCellWithIdentifier("MyCell") as! MyCell
let containerView = UIView(frame:headerView.frame)
headerView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
headerView.myLabel.text = "section title 1"
containerView.addSubview(headerView)
return containerView
This is the Swift 3 version:
let headerView = self.tableView.dequeueReusableCell(withIdentifier: "MyCell") as! MyCell
let containerView = UIView(frame:headerView.frame)
headerView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
headerView.myLabel.text = "section title 1"
containerView.addSubview(headerView)
return containerView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With