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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:59:27+00:00 2026-05-21T14:59:27+00:00

I have created an editable UITableView that supports several custom UITableViewCells of my own

  • 0

I have created an editable UITableView that supports several custom UITableViewCells of my own design. Whenever the user creates a new record or modifies an existing record, they use this UITableView. I have the table view sectioned into groups of tableViewCells using a Grouped Style table view.

When the user is editing a record, I do not want section 1 to display. To achieve this I return 0 when the numberOfRowsInSection method is called. Everything works okay, however there is a “slight visual gap” between section 0 and section 2 that I would like to eliminate if possible. I want to avoid recoding the table view controller to handle indexPaths dynamically. Many of my indexPaths (sections & rows) are hard-coded.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

printf("CustomEntryViewController, -tableView:numberOfRowsInSection:\n");

if (tableView == self.customEntryTableView) {

    if (section == 0) 

        return 1;

    else if (section == 1) {

        if ([self.entryMode isEqualToString:@"ADD"]) 
            return 2;
        else if ([self.entryMode isEqualToString:@"EDIT"])
            return 0;

    }
    else if (section == 2)

        return 1;

    else if (section == 3)

        return 1;

    else if (section == 4 && self.uisegQuantityAnswer.selectedSegmentIndex == 0) 

        return 1;

}

return 0;
}

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-05-21T14:59:27+00:00Added an answer on May 21, 2026 at 2:59 pm

    I found a workaround to the problem. I created two helper methods in my view controller to virtualize the sections that get passed to me by the tableView delegates. The virtual sections cause the logic I’ve written to be skipped over whenever I intend to disable a section in my table view.

    - (NSIndexPath *)virtualIndexPath:(NSIndexPath *)indexPath {
    
        return [NSIndexPath indexPathForRow:indexPath.row inSection:[self virtualSection:indexPath.section]]; 
    
    }
    
    
    - (NSUInteger)virtualSection:(NSUInteger)section {
    
        NSUInteger virtualSection;
    
        if ([self.entryMode isEqualToString:@"ADD"])
    
            virtualSection = section;
    
        else if ([self.entryMode isEqualToString:@"EDIT"]) {
    
            if (section == 0) 
                virtualSection = section;
    
            else if (section > 0)
                virtualSection = section + 1;
    
        }
    
        return virtualSection;
    
    }
    

    I then make a call to one of the above methods throughout the rest of the application.

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
        NSUInteger virtualSection = [self virtualSection:section];
    
        if (tableView == self.customEntryTableView) {
    
            if (virtualSection == 0) {
    
    // Additional code....
    

    In addition to this I also modified -tableView:numberOfSectionsInTableView: method to return the correct number of sections per ADD versus EDIT mode.

    Since this is just a workaround I will keep this question marked unanswered.

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

Sidebar

Related Questions

I have created a custom Array Adapter to bind a custom row that contains
I have created a new Custom Control inheriting from Bar control of DevComponents.DotNetBar controls.
I have an editable UITableView. While my user is re-arranging the cells, I want
I have created some JQuery that will expand a div 'popup' on hover and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a custom post type named People. I have created a page
I have created a function that shows/hides different messages according to a combination of
I have created a dialog and got a problem that only part of the
I have created a filter listview where user will enter input via edittext and
I have created the articles and menu items that links to that articles. This

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.