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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:18:56+00:00 2026-05-31T02:18:56+00:00

I am making a custom table view which has content ‘Static Cells’ and style

  • 0

I am making a custom table view which has content ‘Static Cells’ and style ‘Grouped’. I want to insert static contents programatically. I can do init the view by:

MyCustomViewController *myCustomViewController = [[MyCustomViewController alloc] init];
[self.navigationController pushViewController:myCustomViewController animated:TRUE];

I want to make 3 sections in the table view, one section having 2 cells and the other two sections having 1 cell. Have populated dynamics cells previously but no idea on how to deal with this creation of sections and varying number of cells within. Any solutions?

enter image description here

  • 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-31T02:18:58+00:00Added an answer on May 31, 2026 at 2:18 am

    This should help you!

    - (void)viewDidLoad
    {
    
        [super viewDidLoad];
    
        NSArray *firstSection = [NSArray arrayWithObjects:@"Red", @"Blue", nil];
        NSArray *secondSection = [NSArray arrayWithObjects:@"Orange", @"Green", @"Purple", nil];
        NSArray *thirdSection = [NSArray arrayWithObject:@"Yellow"];
    
        NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:firstSection, secondSection, thirdSection, nil];
        [self setContentsList:array];
        array = nil;
    
    
    }
    - (void)viewWillAppear:(BOOL)animated
    {
    
        [super viewWillAppear:animated];
    
        [[self mainTableView] reloadData];
    
    }
    
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    
        NSInteger sections = [[self contentsList] count];
    
        return sections;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section
    {
    
        NSArray *sectionContents = [[self contentsList] objectAtIndex:section];
        NSInteger rows = [sectionContents count];
    
        NSLog(@"rows is: %d", rows);
        return rows;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        NSArray *sectionContents = [[self contentsList] objectAtIndex:[indexPath section]];
        NSString *contentForThisRow = [sectionContents objectAtIndex:[indexPath row]];
    
        static NSString *CellIdentifier = @"CellIdentifier";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
            {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
    
        [[cell textLabel] setText:contentForThisRow];
    
        return cell;
    }
    
    #pragma mark -
    #pragma mark UITableView Delegate Methods
    
    - (void)tableView:(UITableView *)tableView
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a custom form object in Django which has an overrided __init__
UITableView has custom header UIView , which contains UILabel. Since table has also section
I am making a custom cell which has text fields and as a result
I'm making a custom error dialog in my WPF app and I want to
Hey, I am making a custom table cell right now but my custom cell
If I am making a module, and want to have two custom paths: path/path/path/index.htm
I have a UITableView which I present in a UIPopoverController . The table view
I have been developing one application in iPhone and I'm making custom cells for
We're making a custom boostrapper / external UI for our installation. We want to
I'm using Oracle XE, in which i was making my own custom trigger. For

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.