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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:05:42+00:00 2026-06-04T20:05:42+00:00

I’m trying to come up with a nice (in terms of coding & apperance)

  • 0

I’m trying to come up with a nice (in terms of coding & apperance) way of deleting a section from a table view. Ideally I would like to create a way of deleting sections that is similar to that of the process for deleting a UITableViewCell (ie. the red minus button that shows the red delete button when pressed).

Is there any pre-existing solution to this problem? I have tried doing a bit of research into the are but I can’t really find anything of much use. If there isn’t a pre-existing solution I was thinking I could try and implement one. My plan would be to create a custom header for each section. Within the custom header I’d add the delete buttons that would react the same way as when deleting a row. Do people think this would work?

So to be clear, I’m asking whether there is an existing solution for deleting sections in a UITableView. If there isn’t then I’d like to know if people think my idea would be feasible or if there are any issues I’ve overlooked with 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-04T20:05:44+00:00Added an answer on June 4, 2026 at 8:05 pm

    Implementing your own headerView is the way to go. Apple does not provide a built-in user interface to delete sections. If you pull down the notification area of an iOS device you get an idea how to make it look good.

    The implementation is not very complicated either. I used something like this:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        return 21.0f;
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 21)];
        headerView.backgroundColor = [UIColor lightGrayColor];
    
        UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 0, 250, 21)];
        headerLabel.text = [NSString stringWithFormat:@"Section %d", section];
        headerLabel.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
        headerLabel.textColor = [UIColor whiteColor];
        headerLabel.backgroundColor = [UIColor lightGrayColor];
        [headerView addSubview:headerLabel];
    
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.tag = section + 1000;
        button.frame = CGRectMake(300, 2, 17, 17);
        [button setImage:[UIImage imageNamed:@"31-circle-x"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(deleteButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [headerView addSubview:button];
        return headerView;
    }
    
    - (IBAction)deleteButtonPressed:(UIButton *)sender {
        NSInteger section = sender.tag - 1000;
        [self.objects removeObjectAtIndex:section];
        [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationAutomatic];
    
        // reload sections to get the new titles and tags
        NSInteger sectionCount = [self.objects count];
        NSIndexSet *indexes = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, sectionCount)];
        [self.tableView reloadSections:indexes withRowAnimation:UITableViewRowAnimationNone];
    }
    

    enter image description here

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.