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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:58:41+00:00 2026-05-30T02:58:41+00:00

I have a UITableViewCell, it is scroll-disabled and with fixed sections and rows. There

  • 0

I have a UITableViewCell, it is scroll-disabled and with fixed sections and rows.

There are two sections, with 1 row in section 0, and several rows in section 1.

The tableView is for users to make some choices.

So, the first section (with only one row) is going to display the result of users’ choices,

and no doubt the second section (with several rows) is for choosing.

Now I want to put an image in the cell of the only row of the first section,

and this image will change according to users’ choose.

It is very easy to judge which png image should be displaying, but I have trouble update it.

I tried use the cell’s imageView, and manually alloc a UIImageView or UIView there to display those images.

But all of them won’t work, I mean they just keep what they are displaying at the beginning and never changes it, even if I set the view’s background or its image to a new png.

I tried some method like

[myImage setNeedsDisplay] for the manually alloced view,

or

[thatCell setNeedsDiaplsy] & [self.tableView reloadData] for the imageView of that cell,

but in vain.

So I wonder how can I achieve this function that dynamically display an image in a UITableViewCell in different situations?

Thanks a lot!

_____update line_____

I’m sorry that I didn’t provide my code.

and here they are.

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *inOutTableCellIdentifier = @"DealTableViewIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:inOutTableCellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
                                   reuseIdentifier:inOutTableCellIdentifier] autorelease];
    cell.textLabel.font = [UIFont fontWithName:cMyFont size:[UIFont systemFontSize]];
    cell.detailTextLabel.font = [UIFont fontWithName:cMyFont size:[UIFont smallSystemFontSize]];
     // I tried using both imageView and UIView here, but won't work

     if (indexPath.section == 0) {   
        //cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"moneyCell.png"]];
        cell.backgroundColor = [UIColor cyanColor];
       // cell.imageView.image = [UIImage imageNamed:@"dealDone2.png"];
        self.undoneIcon = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)] autorelease];
        //self.undoneIcon.image = [UIImage imageNamed:@"dealUndone2.png"];
        self.undoneIcon.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"dealUndone2.png"]];
        [cell.contentView addSubview:self.undoneIcon];
        ....  // deal with other rows in section 1
        return cell;
} 
// and this is the method that update the image, the images are named "dealDoneX.png",
// where X is an integer from 0 to 4.
- (void)checkUndoneDegree {  // here I also tried 2 ways corresponding to UIView or a cell's imageView, but neither works well.
int i = 0;
if (self._date)
    i++;
if (self.moneyTextField.text)
    i++;

if (self._incomingAccount)
    i++;
if (self._expensingAccount)
    i++;
if (_dealType != kTransferView)
    if (self._type)
        i++;
NSLog(@"undone degree: %d",i);
NSString *imageName = [@"dealUndone" stringByAppendingFormat:@"%d",i];
self.undoneIcon.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:imageName]];
[self.undoneIcon setNeedsDisplay];
//    NSUInteger p[2] = {0,0};
//    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath    indexPathWithIndexes:p length:2]];
//    [cell setNeedsDisplay];
}

and everytime I update the table’s data, like changing some text of some cell,

I would call [self checkUndoneDegree] and then call [self.tableView reloadData],

But the picture is never updated, at least from the screen.

I even tried to put the codes that decide which png to set in the

  • (UITableViewCell *)tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath {

method, but it can only make the view displaying the first png, without any updating.

Thanks for helping!

  • 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-05-30T02:58:43+00:00Added an answer on May 30, 2026 at 2:58 am
    1. Make your undoneDegree (represented by i variable in your code) an ivar of your view controller, so it is accessible in all of it’s methods, also in the UITableView delegate and data source methods.
    2. Forget about setNeedsDisplay method. Since you are using UITableView to display your content, you need to play by its rules. This means you should use reloadSections:withRowAnimation: method.
    3. Check again if you need self.undoneIcon. I’m pretty sure that imageView property should do. That is if you really want to display an image in the cell. If you want to create some kind of progress bar by manipulating cell’s background, then use backgroundView property, or just place UIProgressView in your cell. This is what I think your want to do, after looking at your code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one problem with two sections in UITableview grouped style. First section having
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is
I have a very simple UITableView that has 3 sections, and 3 rows per
I have a tableview with a section that contains a list of sounds the
I have a UITableViewCell with a UIImage that I'm drawing. As I scroll, I
Inside each UITableViewCell of my UITableView , I have a UIScrollView . The scroll
In my tableview i have set xml data to display but until scroll it
So, idea is the following. I have UITableViewCell, and when I click on it,
I have a UITableViewCell with the UITableViewStyleGrouped style and I would like to change
I have a UITableViewCell and it is UITableViewCellStyleDefault . When I try to put

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.