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 9150925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:40:40+00:00 2026-06-17T11:40:40+00:00

I am having an issue correctly setting the image for UIButtons in a UITableViewCell

  • 0

I am having an issue correctly setting the image for UIButtons in a UITableViewCell. I am using a custom Cell in Storyboard with Four buttons to create a Gallery effect and loading the images from a server using an ImageLoader Delegate like in Apple’s LazyTableImages’ sample code. I am getting the images back from the ImageLoader just fine, the problem is setting the image.

If I set the images in the UITableView cellForRowAtIndexPath, I can set the images fine if they are already loaded or just default images:

for (int i = 0; i < [posts count] && i < [galleryButtons count]; i++)
    {
        post = [posts objectAtIndex:i];
        UIButton *button = [galleryButtons objectAtIndex:i];

        [button setTag:post.userID];

        if (!post.userIcon)
        {

            if (tableView.dragging == NO && tableView.decelerating == NO)
            {
                loadFlag = YES;
            }
            [button setImage:[UIImage imageNamed:@"BtDefault.png"] forState:UIControlStateNormal];
        } else
        {
            [button setImage:post.userIcon forState:UIControlStateNormal];
        }
    }

if (loadFlag)
    {
        [self startIconDownload:posts forIndexPath: indexPath];
    }

However when the delegate calls the ImageDidLoad method later on, the images are not changing.

- (void)postImageDidLoad:(NSIndexPath *)indexPath forColumn:(int)postColumn
{
ImageLoader *imageLoader = [imageDownloadsInProgress objectForKey:indexPath];
Post *post;

if (imageLoader != nil)
{
    UITableViewCell *cell = [timeLineTable cellForRowAtIndexPath:indexPath];


    if (timeLineStyle == 1) //Gallary Style
    {

        int index = (indexPath.row * 4) + postColumn;
        int buttonTag = 200 + postColumn + 1;
        NSLog(@"Button tag is %i", buttonTag);
        post = [currentPosts objectAtIndex:index];
        UIButton *galleryButton = (UIButton *)[cell viewWithTag:buttonTag];
        [galleryButton setImage:post.userIcon forState:UIControlStateNormal];

        UIImageView *imageTester = (UIImageView *)[cell viewWithTag:300];
        [imageTester setImage:post.userIcon];

        [timeLineTable reloadData];

        [cell setHighlighted:YES];

    } else  // Post Style
    {
        UIImageView *userImageView = (UIImageView*)[cell viewWithTag:101];
        UILabel *userNameLabel = (UILabel *)[cell viewWithTag:102];
        [userNameLabel setText:@"Image Loaded"];
        post = [currentPosts objectAtIndex:[indexPath row]];
        [userImageView setImage:post.userIcon];
    }

}
}

You can see I have a UIImage in the cell for testing. This is working just fine. This code also works fine if I remove the for loop in the cellForRowAtIndexPath up above. The problem is without that for loop, the button images are not set if the images are already loaded.

I’m not sure if this is a problem with too many pointers preventing the UIButton from changing. That is all I can think of, but I am pretty new with StoryBoard and this style of Custom Cell manipulation. Thanks for any help.

  • 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-17T11:40:41+00:00Added an answer on June 17, 2026 at 11:40 am

    Up top you set the button tag as [button setTag:post.userID]; but down the bottom you retrieve the button using the tag: int buttonTag = 200 + postColumn + 1;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue getting Appstats to work correctly. Using /appstats or /appstats/stats ends
I am having an issue with setting the background-image of a #x to the
I am setting a cookie, but having some issue. Currently the cookie format is
I'm currently using this jQuery validate plugin and having an issue in IE where
I'm having an Issue with a WPF file not running correctly. On some machines
I'm having some issues getting file uploads to work correctly and the following code
I'm having an issue getting the correct value from my drop down box. Basically
I am currently having an issue with BackgroundWorker running on Windows Server 2003. I
I'm currently having an issue wrapping my brain around the notion of converting my
I'm currently having an issue storing mouse coordinates into an array in which a

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.