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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:28:07+00:00 2026-06-10T04:28:07+00:00

trying to hide and customize the height of a static cell. I know this

  • 0

trying to hide and customize the height of a static cell. I know this might not be the best way to do it. If anyone know of a better way, please advice.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (![Mode isEqualToString:@"HIDE"]) {
        if (indexPath.row == 2) {
            return 0.0;
        }
    }

    return "DEFAUlT_HEIGHT";

}

How to get the default height from the storyboard? Every height of the cells in the storyboard are different. Are there anyway to better customize it? Thanks in advance.

  • 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-10T04:28:08+00:00Added an answer on June 10, 2026 at 4:28 am

    Have a look at this thread : Hide static cells

    It talks about hiding static cells programmatically. Here’s the accepted answer :

    1. Hide the cells

    There is no way to directly hide the cells. UITableViewController is
    the data source which provides the static cells, and currently there
    is no way to tell it “don’t provide cell x”. So we have to provide our
    own data source, which delegates to the UITableViewController in order
    to get the static cells.

    Easiest is to subclass UITableViewController, and override all methods
    which need to behave differently when hiding cells.

    In the simplest case (single section table, all cells have the same
    height), this would go like this:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
        return [super tableView:tableView numberOfRowsInSection:section] - numberOfCellsHidden; }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        // Recalculate indexPath based on hidden cells
        indexPath = [self offsetIndexPath:indexPath];
    
        return [super tableView:tableView cellForRowAtIndexPath:indexPath]; }
    
    - (NSIndexPath*)offsetIndexPath:(NSIndexPath*)indexPath {
        int offsetSection = indexPath.section; // Also offset section if you intend to hide whole sections
        int numberOfCellsHiddenAbove = ... // Calculate how many cells are hidden above the given indexPath.row
        int offsetRow = indexPath.row + numberOfCellsHiddenAbove;
    
        return [NSIndexPathindexPathForRow:offsetRow inSection:offsetSection]; }
    

    If your table has multiple sections, or
    the cells have differing heights, you need to override more methods.
    The same principle applies here: You need to offset indexPath, section
    and row before delegating to super.

    Also keep in mind that the indexPath parameter for methods like
    didSelectRowAtIndexPath: will be different for the same cell,
    depending on state (i.e. the number of cells hidden). So it is
    probably a good idea to always offset any indexPath parameter and work
    with these values.

    2. Animate the change

    As Gareth already stated, you get major glitches if you animate
    changes using reloadSections:withRowAnimation: method.

    I found out that if you call reloadData: immediately afterwards, the
    animation is much improved (only minor glitches left). The table is
    displayed correctly after the animation.

    So what I am doing is:

    - (void)changeState {
         // Change state so cells are hidden/unhidden
         ...
    
        // Reload all sections
        NSIndexSet* reloadSet = [NSIndexSetindexSetWithIndexesInRange:NSMakeRange(0, [self numberOfSectionsInTableView:tableView])];
    
        [tableView reloadSections:reloadSet withRowAnimation:UITableViewRowAnimationAutomatic];
        [tableView reloadData]; }
    

    If this helps, please go over there and up vote henning77’s answer.

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

Sidebar

Related Questions

I'm trying to hide the number pad, but I do not want to implement
Basically I'm trying to hide dropdownlist1 when dropdownlist2's selected value is example. Is this
Am trying to hide this publish 'tick-box' from non-admin users. I used the CanCan
Trying to hide all others, but it keeps affecting the $(this) item. $(function() {
I am trying to hide some divs before the user prints this giant form,
I'm trying to hide the Title field in a list. This doesn't seem to
I'm trying to hide my navigationBar and toolbars on tap, similar to the way
im trying to hide a bee while its movement is not done yet if
Im trying to hide a window using this line of code SetWindowPos(d, IntPtr.Zero, 0,
Im trying to hide a specific image in mouse over and display another image.

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.