I have just finished a project where I use a custom cell for my TableView in Storyboard.
The problem is that when i scroll down the content in each cell is gone, which in my case is two Labels.
This is the code I use to present each cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
MessageCell *cell = (MessageCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Message *messageForRow = (Message *)[messages objectAtIndex:[indexPath row]];
[cell.messageLabel setText:[messageForRow message]];
[cell.senderLabel setText:[messageForRow sender]];
return cell;
}
I have specified the right cellidentifier in storyboard and linked the Class to my custom cell class.
What can be wrong? If there is any needed information I have missed to present, please tell me.
Best regard Robert
Could you check by logging that this method is called when scrolling?
I solved it by myself, the problem did not lie within the update method. By mistake I used the weak signature for the properties in my Message class.
I solved it by using the strong signature instead.
This was a great lesson because I didn't fully understand the concept of strong and weak.