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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:38:38+00:00 2026-05-28T16:38:38+00:00

So I have a cell loaded directly from a nib file: NSArray *cellContents =

  • 0

So I have a cell loaded directly from a nib file:

NSArray *cellContents = [[NSBundle mainBundle] loadNibNamed:@"ResultsTableViewCell" owner:self options:nil];
        cell = [cellContents objectAtIndex:0];

In the nib file, there are a UITableViewCell and Two UIViews, each with its own subviews. Strucuture:

-TableViewCell
   Label 1
   Label 2
-UIView A
   UIView a
   UIView b
   UIImageView c
   UIImageView d
-UIView B
   UIView e
   UIView f
   UIImageView g
   UIImageView h

So the UIView A is connected to the backgroundView property for the UITableViewCell, the UIView B is connected to selectedBackgroundView property.

Problem:
So why A shows up fine as the background for the cell with all it’s subviews, and the UIImageViews in B works fine, but the UIViews in B simply doesn’t show up however I change it? Thanks!

  • 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-28T16:38:39+00:00Added an answer on May 28, 2026 at 4:38 pm

    Here’s what I found my case. When I logged the RGB and alpha of the UIView’s background color, I found that they were all getting set to 0 when the cell was selected:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        CGFloat red, green, blue, alpha;
        [viewE.backgroundColor getRed:&red green:&green blue:&blue alpha:&alpha];
        NSLog(@"Selected: Red=%f, Green=%f, Blue=%f, alpha=%f", red, green, blue, alpha);
    }
    
    -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
        CGFloat red, green, blue, alpha;
        [viewE.backgroundColor getRed:&red green:&green blue:&blue alpha:&alpha];
        NSLog(@"Deslected: Red=%f, Green=%f, Blue=%f, alpha=%f", red, green, blue, alpha);
    }
    

    Initially, nothing is selected. Tap a row in the table and the log shows:

    Selected: Red=0.000000, Blue=0.000000, Green=0.000000, alpha=0.000000
    

    and my subview does not appear (Note Alpha=0). Funny because when I logged viewE.alpha, it showed it was 1.

    Tap the row again to deselect it:

    Deselected: Red=0.667000, Blue=0.776000, Green=0.220000, alpha=1.000000
    

    That’s what I expect.

    My table cell is a custom UITableViewCell. So in my custom UITableViewCell class I added this code:

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        UIColor *saveColor = self.viewE.backgroundColor;
        [super setSelected:selected animated:animated];
        if (selected)
            self.viewE.backgroundColor = saveColor;
    }
    

    Now the subview viewE appears when the cell is selected.

    It seems like the code here is compensating for a condition that should not have existed in the first place, but it works!

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

Sidebar

Related Questions

I have one UITableView with a custom cell loaded from a nib file, it
I have a UITableview made up with a custom cell loaded from a nib.
I have customized UITableViewCell (Static Content Loaded from nib). This cell contains one UILable
I have an table view where i am loaded custom cell from different nib,
I have TableView with a custom TableViewCell loaded from an external nib file. Each
I have custom table view cell with images (loaded from app document directory), labels,
I have a tableview with each cell loaded from a xib. It is in
Hi i have UITableView with x rows and my cell data loaded with plist
I have an tableview which is loaded from a mutablearray as listed below. However
I have the items for a combo box being loaded from a store but

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.