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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:11:56+00:00 2026-06-17T19:11:56+00:00

I am using some static UITableViewCell ‘s configured in the Storyboard to display some

  • 0

I am using some static UITableViewCell‘s configured in the Storyboard to display some setting information.

Some of the other cells should be disabled if one of the other settings is toggled off.

In order to put the cells into the proper state, during viewWillAppear I read the settings from NSUserDefaults and then change the cells accordingly.

- (void) viewWillAppear:(BOOL)animated
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OtherCellEnabled"]) {
            [self otherCell].alpha = 1.0;
            [self otherCell].userInteractionEnabled = YES;
        }
        else {
            NSLog(@"Changing alpha to 0.3");
            [self otherCell].alpha = 0.3;
            [self otherCell].userInteractionEnabled = NO;
        }

The problem is that when I actually run the program, even though it says in the log that the alpha is changed, the alpha doesn’t actually change. The userInteractionEnabled does seem to stick, but the alpha is left at 1.0.

It’s not a problem of cell reuse, or cell’s not being instantiated in time, because the other settings can be changed just fine.

Changing it from cell.alpha to cell.contentView.alpha works, but that is a different setting.

It seems like all of the settings “stick” except for the alpha setting, which somehow is getting overwritten.

  • 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-17T19:11:58+00:00Added an answer on June 17, 2026 at 7:11 pm

    I am answering my own question because I was able to solve it.

    First, I tried putting the alpha change in cellForRowAtIndexPath, but that didn’t work either. After a lot of tinkering, I’ve come to the conclusion that UITableViewCell‘s alpha setting is somehow special in that it keeps getting overwritten or set to 1.0.

    I found two fixes:

    First, instead of doing the change in cellForRowAtIndexPath, do it in the UITableViewDelegate method willDisplayCell. For whatever reason, changing the cell’s alpha in this method will actually stick. Of course, if you do it this way you have to re-arrange your logic so that the changes are done on a cell-by-cell basis, i.e.:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell  
                                             forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (cell == [self otherCell]) {
        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OtherCellEnabled"]) {
            cell.alpha = 1.0;
            cell.userInteractionEnabled = YES;
        }
        else {
            NSLog(@"Changing alpha to 0.3");
            cell.alpha = 0.3;
            cell.userInteractionEnabled = NO;
        }
    }
    }
    

    As I said, I’m not sure exactly why this works in willDisplayCell but not in cellForRowAtIndexPath. Others seem uncertain also:

    What is -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] for?

    UITableView background with alpha color causing problem with UITableViewCell

    The other solution is to, instead of using the problematic alpha, use another setting which will achieve the same effect. In my case, that was the contentView.alpha and the backgroundColor. For whatever reason, these settings will stick, and you can even set them in viewWillAppear and it will work as expected:

    - (void) viewWillAppear:(BOOL)animated {
        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OtherCellEnabled"]) {
                [self otherCell].backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
                [self otherCell].contentView.alpha = 1.0;
                [self otherCell].userInteractionEnabled = YES;
            }
            else {
                NSLog(@"Changing alpha to 0.3");
                [self otherCell].backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.3];
                [self otherCell].contentView.alpha = 0.3;
                [self otherCell].userInteractionEnabled = NO;
            }
    }
    

    The disadvantage to the second approach is that now you are overwriting the Storyboard’s cell color settings, but you could work around that by asking the storyboard for the color if you care about that.

    I’m not sure why cell.alpha is treated differently. Maybe something about the way static cells are implemented.

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

Sidebar

Related Questions

I am using a static UITableview, set up in a storyboard. For some cells
I have one project using storyboard. I have one UIView and I put some
I'm facing a similar issue like this one . I'm using some static class
I'm using HAML to generate some static html pages for a site, and I
So I'm using the ProgressBar JQuery plugin ( http://t.wits.sg/misc/jQueryProgressBar/demo.php ) to create some static
I'm using carbide c++. What to put in .mmp file to link some static
I have some code which I'm currently using to change the static-IP of a
I have refactored some UIView sub-classes into a static library. However, when using Interface
I was planning on hosting some static webpages and I was interested in using
I'm trying to start serving some static web pages using connect like this: var

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.