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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:25:07+00:00 2026-06-06T20:25:07+00:00

I have a UITableViewCell nib file in which there is a UIImageView and a

  • 0

I have a UITableViewCell nib file in which there is a UIImageView and a UILabel. I have outlets for both of these to my controller as well as an outlet for the cell itself. I am setting the label and image programmatically, but the image does not show up.

So I went to test it, and even if I set the image itself in the nib file, it does not show up. If I set the background color, it shows up fine. Any ideas? I’m stuck.

It seems to be unrelated to code, in my mind, since it doesn’t even work via nib file. But here it is anyway in case it helps somehow.

MyViewController.h

@interface MyViewController : UITableViewController

@property (strong, nonatomic) MyModel *myModel;
@property (strong, nonatomic) NSArray *tableViewCells;

@property (strong, nonatomic) IBOutlet UITableViewCell *tableViewCell;
@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@property (weak, nonatomic) IBOutlet UIImageView *myImage;

@end

MyViewController.m

@interface MyViewController ()

- (void)bindMyModel:(MyModel*)model toView:(UITableViewCell*)view;

- (UITableViewCell*)copyUITableViewCell:(UITableViewCell*)cell;

@end

@implementation MenuViewController

@synthesize myModel = _myModel;
@synthesize tableViewCells = _tableViewCells;

@synthesize tableViewCell = _tableViewCell;
@synthesize myLabel = _myLabel;
@synthesize myImage = _myImage;

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray *cells = [[NSMutableArray alloc] init];
    [MyModel loadAndOnSuccess:^(id data, id context) {
        self.myModel = data;
        for (MyModel *item in self.myModel.items) {
            [[NSBundle mainBundle] loadNibNamed:@"TableCellNib" owner:self options:nil];
            [self bindMyModel:item toView:self.tableViewCell];
            [cells addObject:[self copyUITableViewCell:self.tableViewCell]];
            self.tableViewCell = nil;
        }
        self.tableViewCells = [[NSArray alloc] initWithArray:cells];
    } onFail:^(NSString *error, id context) {
        NSLog(@"FAIL with error: %@", error);
    }];
}

- (void)viewDidUnload
{
    [self setTableViewCell:nil];
    [self setMyLabel:nil];
    [self setMyImage:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (void) bindMyModel:(MyModel*)model toView:(UITableViewCell*)view
{
    if (view) {
        self.myLabel.text = model.myLabelText;
        self.myImage.image = model.myImageResource;
        self.myLabel = nil;
        self.myImage = nil;
    }
}

- (UITableViewCell*)copyUITableViewCell:(UITableViewCell*)cell
{
    NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject: cell];
    return [NSKeyedUnarchiver unarchiveObjectWithData: archivedData];
}

#pragma mark - Table view data source

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [self.tableViewCells objectAtIndex:indexPath.row];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.myModel.items.count;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Irrelevant code here
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ((UITableViewCell*)[self.tableViewCells objectAtIndex:indexPath.row]).frame.size.height;
}

@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-06T20:25:08+00:00Added an answer on June 6, 2026 at 8:25 pm

    You are trying to use two IBOutlets on your UITableViewController to populate a multitude of UILabels and UIImageViews that are part of the UITableViewCell. You need to create a custom subclass of UITableViewCell and add the IBOutlets to that subclass.

    @interface CustomCell : UITableViewCell
    
    @property (weak, nonatomic) IBOutlet UILabel *myLabel;
    @property (weak, nonatomic) IBOutlet UIImageView *myImage;
    
    @end
    

    then in your bindMyModel:toView:

    - (void) bindMyModel:(MyModel*)model toView:(CustomCell*)view
    {
        if (view) {
            view.myLabel.text = model.myLabelText;
            view.myImage.image = model.myImageResource;
        }
    }
    

    Now you have independent IBOutlets for each of your Cells. You will also need to change some of your bindings as well. This is a fix, but honestly I would rewrite a lot of the code and just use dequeueReusableCellWithIdentifier in your cellForRowAtIndexPath call, and keep a pool of CustomCells that you will reuse, and just set up the myLabel.text and myImage.image in the cellForRowAtIndexPath call.

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

Sidebar

Related Questions

I have UItableViewCell created with a nib file, and have put in my cell
In my nib file, I have an outlet connected a UIButton for the UITableViewCell.
I have created a UITableViewCell with a NIB file. There is 1 label in
Hi have setup a UITableViewCell from a nib file and everything is working as
So I have a cell loaded directly from a nib file: NSArray *cellContents =
I have customized UITableViewCell (Static Content Loaded from nib). This cell contains one UILable
I have a UITableView controller, UITableView xib, and two UITableViewCell subclasses with there xib's.
I have a NIB file with a UIView, a couple of UIImageView's (including a
i have make a custom cell in nib file with delegate. I have define
I have a nib-based table view cell which I created in Interface builder. 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.