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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:55:17+00:00 2026-05-27T16:55:17+00:00

I started a new project, and I chose to use ARC, but I’ve got

  • 0

I started a new project, and I chose to use ARC, but I’ve got a pretty weird issue.
I’ve got a subclass of UITableViewCell that has 2 sizes depending on wether the user long presses the cell or not.
When the size changes, it reveals another part of the cell with a different background that partly overlaps the actual cell background.
To do so, I have a property @property (strong, nonatomic, retain) UIImageView* optionsImageView;
I tried different stuff but they all lead to the same result, so I’ll just explain the one actually coded.
In the init method, I create the optionsImageView and adds it to self as flollows :

UIImage* image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sous_menu" ofType:@"png"]];
    self.optionsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 
                                                                          self.frame.size.height - 12, 
                                                                          self.frame.size.width, 
                                                                          image.size.height)];
    optionsImageView.backgroundColor = [UIColor clearColor];
    optionsImageView.image = image;
    [self insertSubview:optionsImageView aboveSubview:self.backgroundView];  
    optionsImageView.alpha = 0;

When the user long presses the cell, I change the alpha of the optionsImageView.
But when I inspect it in the layoutSubviews method, optionImageView is nil, so are other members of my class.

#pragma mark - ACTIONS
- (void)hideOptionsPanel
{
    NSLog(@"hideOptionsPanel for %@", titleLabel.text);
    self._cellOptions = LRCellOptionsHidden;
    NSLog(@"_cellOptions %d", self._cellOptions);
    self.optionsImageView.alpha = 0;
}

- (void)showOptionsPanel
{
    NSLog(@"showOptionsPanel for %@", titleLabel.text);
    self._cellOptions = LRCellOptionsShown;
    NSLog(@"_cellOptions %d (optionsImageView %@)", self._cellOptions, optionsImageView);
    self.optionsImageView.alpha = 1;
}

- (void)layoutSubviews
{
    NSLog(@"layoutSubviews for %@ (%d)", titleLabel.text, self._cellOptions);
    // rounded corners
    self.icon.layer.cornerRadius = 5.0;
    self.icon.clipsToBounds = YES;
}

and here is the ouptput for all of this….

2011-12-24 14:11:31.788 LendReminder[11189:fb03] layoutSubviews for Cars 2 Bluray (0)
2011-12-24 14:11:32.137 LendReminder[11189:fb03] showOptionsPanel for Cars 2 Bluray
2011-12-24 14:11:32.138 LendReminder[11189:fb03] _cellOptions 1 (optionsImageView (null))
2011-12-24 14:11:32.140 LendReminder[11189:fb03] layoutSubviews for Cars 2 Bluray (0)
2011-12-24 14:11:32.141 LendReminder[11189:fb03] layoutSubviews for Cars 2 Bluray (0)
2011-12-24 14:11:33.442 LendReminder[11189:fb03] layoutSubviews for Sleepy Hollow (0)
2011-12-24 14:11:33.790 LendReminder[11189:fb03] hideOptionsPanel for Cars 2 Bluray
2011-12-24 14:11:33.791 LendReminder[11189:fb03] _cellOptions 0
2011-12-24 14:11:33.793 LendReminder[11189:fb03] showOptionsPanel for Sleepy Hollow
2011-12-24 14:11:33.793 LendReminder[11189:fb03] _cellOptions 1 (optionsImageView (null))
2011-12-24 14:11:33.796 LendReminder[11189:fb03] layoutSubviews for Sleepy Hollow (0)
2011-12-24 14:11:33.796 LendReminder[11189:fb03] layoutSubviews for Cars 2 Bluray (0)
2011-12-24 14:11:33.797 LendReminder[11189:fb03] layoutSubviews for Sleepy Hollow (0)

You can see that in the showOptionsPanel and HideOptionPanel, the option Enum is ok whilst in the layoutSubviews, it is still equal to 0 and the optionView is nil…
What the hell? Is this something that has to do with ARC or what?
Thx.

  • 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-27T16:55:18+00:00Added an answer on May 27, 2026 at 4:55 pm

    I got it ;))
    I did not set the reuseIdentifier in the xib, so each time I called cellAtIndexPath, the cell was rebuild, hence nil pointers. I suck I know 😀 😀 😀

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

Sidebar

Related Questions

I just started a new iOS project and chose to use Core Data with
I have started a new mvc project and clicked on project\properties\web - use local
I have started a new project on Google code, and I chose Mercurial as
I started new project in XCode 4.2 without Automatic Reference Counting and without Use
We started a new project and the nature of the project is very interactive
I have just started a new project, and I am using the Delphi 2009
I started doing a new project in PHP / MySql . The Aim of
I recently started a new personal project to learn Entity Framework. My end goal
I've recently started my new private project. The main goal which I want to
I'm working on a fairly new project and we started from scratch. So not

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.