Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:20:28+00:00 2026-06-11T18:20:28+00:00

Code works fine until I changed UIViewController with tableView to UICollectionViewController . Now all

  • 0

Code works fine until I changed UIViewController with tableView to UICollectionViewController.

Now all cells shows same image, sometimes it flipping to nil.
However textLabels are OK.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TourGridCell";
    TourGridCell *cell = (TourGridCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    Guide *guideRecord = [self.fetchedResultsController objectAtIndexPath:indexPath];

    cell.titleLabel.text = [guideRecord.name uppercaseString];

    cell.titleLabel.backgroundColor = [UIColor clearColor];
    if ([guideRecord.sights count] > 0) {

        if ([[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"]) {
            cell.imageView.image = [UIImage drawImage:[[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"] inImage:[UIImage imageNamed:@"MultiplePhotos"] inRect:CGRectMake(11, 11, 63, 63)];

        }else {
            cell.imageView.image = [UIImage imageNamed:@"placeholder2"];
        }

        NSMutableString *sightsSummary = [NSMutableString stringWithCapacity:[guideRecord.sights count]];
        for (Sight *sight in guideRecord.sights) {
            if ([sight.name length]) {
                if ([sightsSummary length]) {
                    [sightsSummary appendString:@", "];
                }
                [sightsSummary appendString:sight.name];

            }
        }
        if ([sightsSummary length]) {
            [sightsSummary appendString:@"."];
        }
        cell.sightsTextLabel.text = sightsSummary;
        cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i", nil) , [guideRecord.sights count]];
        cell.detailTextLabel.hidden = NO;
        //        cell.textLabel.alpha = 0.7;
        NSPredicate *enabledSightPredicate = [NSPredicate predicateWithFormat:@"notify == YES"];
        NSArray *sightsEnabled = [[[guideRecord.sights array] filteredArrayUsingPredicate:enabledSightPredicate]mutableCopy];
        NSPredicate *visitedSightPredicate = [NSPredicate predicateWithFormat:@"visited == YES"];
        NSArray *sightsVisited = [[[guideRecord.sights array] filteredArrayUsingPredicate:visitedSightPredicate]mutableCopy];

        if ([sightsEnabled count] > 0)
        {
            NSLog(@"green_badge");
            cell.notifyIV.image = [UIImage imageNamed:@"green_badge"];
        }
        else if (sightsVisited.count == 0) {
            NSLog(@"new_badge");
            cell.notifyIV.image = [UIImage imageNamed:@"new_badge"];
        }
        else
        {
            cell.notifyIV.image = nil;
        }

    }
    else {
        cell.notifyIV.hidden = YES;
        //        cell.textLabel.textColor = RGB(0, 50, 140);
        cell.detailTextLabel.hidden = YES;
        cell.sightsTextLabel.text = nil;
    }

    return cell;
}

Cell set up in storyboard,

//  TourGridCell.h
#import <UIKit/UIKit.h>

@interface TourGridCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIImageView *notifyIV;
@property (weak, nonatomic) IBOutlet UILabel *textLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *sightsTextLabel;

@end


#import "TourGridCell.h"

@implementation TourGridCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:20:29+00:00Added an answer on June 11, 2026 at 6:20 pm

    Solution is to nullify image each time in cellForItemAtIndexPath:

    cell.imageView.image = nil;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this code works fine until I start scrolling: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
All my code works fine until i did some changes that i cant track
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
This code works fine, but I'll want to handle exception if any thing goes
This code works fine to find an available room within certain date, but it
This code works fine in C#: Expression.Lambda(LambdaBody); But none of the methods for building
My code works fine when I call AA.sendRequest() from the console, but not when
The following code works fine on Linux but throws an exception on OS X
The following code works fine in firefox but as with many other things, I
the following piece of code works fine when i use it among some code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.