在更新特定的uitableviewcell中的uibutton時出現問題。當我更改按鈕顏色時,它將更新uitableview中的每個按鈕。附上我下面的代碼:更改特定單元的UIButton
PFObject *post = [self.objectArray objectAtIndex:indexPath.section];
cell.likeBtn.layer.cornerRadius = 5.0f;
//To access button methods
[cell.likeBtn setTag:indexPath.section];
NSMutableDictionary *attributes = [NSMutableDictionary
dictionaryWithDictionary:[[TMMemoryCache sharedCache] objectForKey:post.objectId]];
BOOL likedByCurrentUser = [[attributes objectForKey:@"likedByCurrentUser"] boolValue];
if (likedByCurrentUser) {
cell.likeBtn.backgroundColor = [UIColor flatRedColor];
[cell.likeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cell.likeBtn setTitle:@"Liked" forState:UIControlStateNormal];
}else{
//NSLog(@"Did not like %@", post.objectId);
cell.likeBtn.backgroundColor = [UIColor flatBlueColor];
[cell.likeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cell.likeBtn setTitle:@"Like" forState:UIControlStateNormal];
}
是他們的一個更好的辦法只在一個特定的細胞更新的UIButton?
你把這段代碼放在哪裏? – hariszaman