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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:45:17+00:00 2026-05-22T20:45:17+00:00

Why is the following not displaying the proper UITableView accessory view? It is simply

  • 0

Why is the following not displaying the proper UITableView accessory view? It is simply displaying the UIAcessoryTypeCheckmark that was selected in the nib file.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForManagedObject:(NSManagedObject *)managedObject withIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier = @"Selection";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil) {
        cell = tvCell;
        self.tvCell = nil;
    }   
    self.tableView.rowHeight = 70.0f;

    //Background
    BOOL useDarkBackground = NO; //odd
    if(indexPath.row %2 == 0) useDarkBackground = YES; //even
    NSString *backgroundImagePath = [[NSBundle mainBundle] pathForResource:useDarkBackground ? @"DarkBackground" : @"LightBackground" ofType:@"png"];
    UIImage *backgroundImage = [[UIImage imageWithContentsOfFile:backgroundImagePath] stretchableImageWithLeftCapWidth:0.0 topCapHeight:1.0];
    cell.backgroundView = [[[UIImageView alloc] initWithImage:backgroundImage] autorelease];
    cell.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    cell.backgroundView.frame = cell.bounds;

    //Checkmark
    cell.userInteractionEnabled = YES;
    NSString *checkmarkImagePath;
    checkmarkImagePath = [[NSBundle mainBundle] pathForResource:[selectedObjects containsObject:managedObject] ? @"checkSelected" : @"checkUnselected" ofType:@"png"];
    if([selectedObjects count] == 0) {
        checkmarkImagePath = [[NSBundle mainBundle] pathForResource:@"checkUnselected" ofType:@"png"];
    }   
            UIImage *checkmarkImage = [[UIImage imageWithContentsOfFile:checkmarkImagePath] stretchableImageWithLeftCapWidth:0.0 topCapHeight:1.0];
    UIImageView *imageView = [[[UIImageView alloc] initWithImage:checkmarkImage] autorelease];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    imageView.frame = CGRectMake(10.0, 10.0, imageView.frame.size.width/1.2, imageView.frame.size.height/1.2);

    return cell;

}

For some reason, the following does work:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *objectToChange = [[self fetchedResultsControllerForTableView:tableView] objectAtIndexPath:indexPath]; //The object

[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO];

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

NSString *checkmarkImagePath = [[NSBundle mainBundle] pathForResource:[selectedObjects containsObject:objectToChange] ? @"checkSelected" : @"checkUnselected" ofType:@"png"];
UIImage *checkmarkImage = [[UIImage imageWithContentsOfFile:checkmarkImagePath] stretchableImageWithLeftCapWidth:0.0 topCapHeight:1.0];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:checkmarkImage] autorelease];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.frame = CGRectMake(10.0, 10.0, imageView.frame.size.width/1.2, imageView.frame.size.height/1.2);

cell.accessoryView = imageView;
}

Thanks a lot!

  • 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-22T20:45:17+00:00Added an answer on May 22, 2026 at 8:45 pm

    It doesn’t look like you’re adding the UIImageView to the accessory view of the cell in the first code block.

    You’re also leaking all over the place. Make sure you adhere to the memory management guidelines set forth by Apple.

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

Sidebar

Related Questions

Learning CasperJS Trying to understand why the following is not displaying my results in
I have an issue with a particular controller action not displaying the view. Here
I am using following code. When the query crashes, it is not displaying the
The following jQuery autocomplete code is not displaying the results in MVC3. When I
I write the following to alert but it is not displaying the alert box
I am using following code, but my progress bar is not displaying in the
The following code is not displaying the image from IIS 6/PHP 5.2.9. It works
I have the following code, but the alert box is not displaying. try {
Why does the following not work: #include <iostream> #include <fstream> #include <stack> std::stack<std::ifstream> s;
Why does the following not give an error? for (int i=0; i<10; ++i) //

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.