Okay, so after checking a lot of SO answers, I am posting this. I am trying to make a custom a uitableviewCell in which i have one uiimageview and uilabel. The problem is when i load cells, it loads alternate images in uitableview only, also loads correct data for uilabel for each cell. It should load images on all the cells And sometimes misplaces the images in wrong cells also
Here is what i am doing...
Step 1:
#define kActivityCell @"ActivityCell"
Step 2:
[self.feedTable registerNib:[UINib nibWithNibName:kActivityCell bundle:nil]
forCellReuseIdentifier:kActivityCell];
Step 3:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// format for feeds
NSLog(@"row no: %d",indexPath.row);
ActivityCell *activityCell = (ActivityCell *)[tableView dequeueReusableCellWithIdentifier:kActivityCell forIndexPath:indexPath];
//selection color
UIView *selectionColor = [[UIView alloc] init];
selectionColor.backgroundColor = [GeneralUtils colorWithString:kTableSelectionHEX];
activityCell.selectedBackgroundView = selectionColor;
[activityCell listOfLikeSetting];
ZDUser *newObject = [likeArray objectAtIndex:indexPath.row];
activityCell.nameAndDesc.text = newObject.display_name;
activityCell.nameAndDesc.font = [GeneralUtils FontSettingBold13];
activityCell.objectID = newObject.userID;
activityCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// this method is from AFNetworking Lib
[activityCell.photoLeft setImageWithURL:[NSURL URLWithString:newObject.avatar]];
// this is my own method to cache images, but i am not using it right now.
// [activityCell.photoLeft setProfileImageFor:newObject.avatar];
return activityCell;
}
I have created a separate class for ActivityCell and xib is there in which i have made the connections properly for iboutlet uiimageview photoleft
As per now, i am clueless why its happening anybody pls share your thoughts... here are some of the links which i have read , but it didn't help me.
Lazy load images in UITableViewCell