Ok. I cant seem to get a firm understanding on how tableviews work. Would someone please explain to me how cells are reused in tableviews especially when scrolling? One of t
I need to see your code, but i can say u didn't change your model or you changed it all of rows in your array.
You can use some class extended from UITableViewCell and in "cellForRowAtIndexPath" method use it as reusable cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
// Configure the cell...
MyModel *model = [_models objectAtIndex:indexPath.row];
cell.nameLabel.text = model.name;
cell.image.image = model.image;
cell.likeButton.text = model.likeButtonText;
return cell;
}
and then in your "didSelectRowAtIndexPath" method change "model.likeButtonText".
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
MyCell cell* = [tableView cellForRowAtIndexPath:indexPath];
MyModel *model = [_models objectAtIndex:indexPath.row];
model.likeButtonText = [model.likeButtonText isEqual:@"like"]?@"unlike":@like;
cell.likeButton.text = model.likeButtonText;
}
This will update your cell