I set the image uploaded using sdwebimage to my UITableViewCell . To keep the UITableView displaying invalid images, I need to set the nil image to prepareForReuse . However, I have some problems with this.
Here I set the image:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * reuseIdentifier = @"programmaticCell"; MGSwipeTableCell * cell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (!cell) { cell = [[MGSwipeTableCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier]; } CGFloat brightness = [UIScreen mainScreen].brightness; cell.textLabel.text = [self.streams[indexPath.row] name]; cell.detailTextLabel.text = [self.streams[indexPath.row] published]; NSString *imageUrl = [NSString stringWithFormat: @"%@", [self.streams[indexPath.row] photo]]; NSLog(@"Image is: %@ and path is: %d", imageUrl, indexPath.row); [cell.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"tile-blue.png"] options:indexPath.row == 0 ? SDWebImageRefreshCached : 0]; cell.delegate = self;
When I implement - (void)prepareForSegue , Xcode keeps throwing errors saying that cell not available to it. What is the correct way to implement this?
ios objective-c uitableview
user4334509
source share