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

  • Home
  • SEARCH
  • 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 7719355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:23:46+00:00 2026-06-01T03:23:46+00:00

I have a UITableView with 3 sections, each returning for numberOfRows the count in

  • 0

I have a UITableView with 3 sections, each returning for numberOfRows the count in 3 separate arrays. In my cellForRow, I need to be able to detect which cell is the first cell in the table and which is the last.

The tricky part is that sometimes a section can return a count of 0 for number of rows, so I’m having a hard time figuring this out. All I’m trying to do is set two flags: isTopCell and isBottomCell. Any ideas?

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(section==0)
        return [array1 count];
    else if(section==1)
        return [array2 count];
    else return [array3 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 if(/*something, what I'm trying to figure out*/)
      isTopCell=YES;
 if(/*something, what I'm trying to figure out*/)
      isBottomCell=YES;
}

Edit: Let me clarify. The 3 sections are unified. I want to determine the overall top and bottom cell. if(indexPath.row==0) will return true for 3 sections. I need only 1 winner.

  • 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-01T03:23:47+00:00Added an answer on June 1, 2026 at 3:23 am

    Try this:

    int index = indexPath.row;
    if (indexPath.section > 0) index += [array1 count];
    if (indexPath.section > 1) index += [array2 count];
    
    if (index == 0) // Top row
    
    if (index == [array1 count] + [array2 count] + [array3 count] - 1) // Bottom row
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView with each cell being broken into several sections with a
So I have my UITableView, with 2 sections and 1 cell in each, and
I have a simple UITableView with two sections. Each section has a header which
I have a UITableView with two sections: free and paid. Each section has a
I have a UITableView with two sections, which are both empty when my application
I have a UITableView with 8 cells(sections) in total in which 6 of them
I have a UITableView. I'm population it from a NSDictionary with arrays for each
I have a UITableView with custom background images in each cell. The bottom cell
I have set up a UITableView which has 3 sections in, with 3 rows
I have a UITableView with two sections. Each section has a few UITableViewCells .

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.