Reputation: 2773
I tried to read a few posts here on stackover but I could not understand how to solve my problem ...
I have a tableview Dynamics, I'm using parse.com for gestionie data in my tableView I have a custom cell where there is a button that sends a friend request the USER is selected.
Also with a query recall all friend requests already submitted ... Once these requirements are shown with the query button of the various user (in Tableview) changes color.
So far so good ... the only problem is that I can not seem to store the state of the button ... for example:
A user wants to send "A" a friend request, by this time the color of the button changes but when the tableView scrolls the button again returns to the original color as if it had never been clicked ...
How can I fix this?
information: The action This button is located in the custom cell (with a class) and refer to two delegates in the main view controller.
-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
NPCustomFindUserCell *cell =[tableViewFindUser dequeueReusableCellWithIdentifier:CellIdentifier];
if ([self.cellsCurrentlyEditing containsObject:indexPath]) {
[cell openCell];
}
cell.delegate = self;
cell.addUserButton.tag = indexPath.row;
PFUser *user = [self.userArray objectAtIndex:indexPath.row];
if (!isFiltered) {
PFObject *object = [userArray objectAtIndex:indexPath.row];
if (![self Is_InAttesa:user]) {
cell.addUserButton.tintColor = [UIColor colorWithRed:(167/255.0) green:(103/255.0) blue:(91/255.0) alpha:(1)];
}
else {
cell.addUserButton.tintColor = [UIColor grayColor];
}
cell.user_photoProfile.image = [UIImage imageNamed:@"camera"];
cell.user_photoProfile.layer.masksToBounds = YES;
cell.user_photoProfile.layer.cornerRadius = 3.0f;
cell.user_photoProfile.contentMode = UIViewContentModeScaleAspectFill;
cell.user_photoProfile.file = [object objectForKey:NPUserKey_PHOTOPROFILE];
[cell.user_photoProfile loadInBackground];
NSString *nameText = [object objectForKey:NPUserKey_NOMECOGNOME];
cell.label_UserNomeCognome.text = nameText;
cell.itemText = nameText;
}
else {
PFObject *OggettiFiltrati = [userFiltrati objectAtIndex:indexPath.row];
cell.user_photoProfile.file = [OggettiFiltrati objectForKey:NPUserKey_PHOTOPROFILE];
cell.user_photoProfile.image = [UIImage imageNamed:@"camera"];
[cell.user_photoProfile.layer setMasksToBounds:YES];
[cell.user_photoProfile .layer setCornerRadius:5.0f];
cell.user_photoProfile.contentMode = UIViewContentModeScaleAspectFill;
[cell.user_photoProfile loadInBackground];
NSString *str = [OggettiFiltrati objectForKey:NPUserKey_NOMECOGNOME];
cell.label_UserNomeCognome.text = str;
cell.itemText = str;
}
return cell;
}
Upvotes: 0
Views: 60
Reputation: 3429
You need to base the state of your cell off of your data model that populates the cell. You should have something in your model indicate to the cell that the button should be active/disabled/etc.
Upvotes: 1