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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:02:32+00:00 2026-05-28T08:02:32+00:00

When customizing an UITableView, how can I know wether the cell is the first,

  • 0

When customizing an UITableView, how can I know wether the cell is the first, last or only one in the section in the

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath` 

method?

Thanks.

  • 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-28T08:02:32+00:00Added an answer on May 28, 2026 at 8:02 am

    To find out if it is the last row in a section, call tableView:numberOfRowsInSection: on the data source delegate (presumably, it’s self, since you are in a tableView:cellForRowAtIndexPath: method). If the value returned from that method equals indexPath.row+1, you are at the last row. If additionally indexPath.row == 0, you are at the only row. If indexPath.row == 0 but tableView:numberOfRowsInSection: returned a number other than 1, you are looking at the first row in a section.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        NSUInteger count = [self tableView:tableView numberOfRowsInSection:indexPath.section];
        BOOL first = indexPath.row == 0;
        BOOL last = indexPath.row+1 == count;
        if (first && last) {
            NSLog(@"The only cell in section %d", indexPath.section);
        } else if (first) {
            NSLog(@"The first cell in section %d", indexPath.section);
        } else if (last) {
            NSLog(@"The last cell in section %d", indexPath.section);
        } else {
            NSLog(@"Nothing special...");
        }
        // Do the rest of your work
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During practice of customizing VirtualPathProvider, I found that it the custom VirtualPathProvider can be
I want to remove the default blue color of uitableview cell selection. I don't
I am customizing my UITableView and I figured out how to set the selected
I have used Cell.ContentView in my implementation for customizing the cell contents. It works
I've been customizing the Jquery UI auto-complete to ensure that users submit only data
I am customizing an SSRS report, using an existing DataSource and DataSet. I can't
Now Im customizing title bar of my application. My aim is to add one
I'm finding customizing UITableView's separator line graphics. It's basically a single line and it
I'm customizing a UITableView . I want to hide the line separating on the
I'm customizing the MVC music store to fit my needs in MVC3. The one

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.