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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:28:47+00:00 2026-06-01T13:28:47+00:00

I have 2 sections within a table view and I have loaded one section

  • 0

I have 2 sections within a table view and I have loaded one section from one array and one from another. How can I set cell values for both sections?

I’m using the following code:

Title For Header Section.

   - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:                             (NSInteger)section
   {
        if(section == 0)       
            return @" Scheduled Patients ";
        else
            return @" Walk In Patients ";
   }

Rows in Section:

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

    if(section==0)
        return [resultArray count];
    else {
      EMRAppDelegate *appDelegate = (EMRAppDelegate *)[[UIApplication sharedApplication] delegate];
      return [appDelegate.walkPatients count];
    }
  }


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


     {
       UIButton * uploadButton = nil;
       static NSString * Identifier = @"Identifier";
       UITableViewCell * cell = [table dequeueReusableCellWithIdentifier:Identifier];
      if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier] autorelease];
       uploadButton = [UIButton buttonWithType:UIButtonTypeCustom];
       [uploadButton setFrame:CGRectMake(10, 10, 24, 24)];
       [uploadButton setImage:[UIImage imageNamed:@"upload.png"] forState:UIControlStateNormal];
       [uploadButton addTarget:self action:@selector(onUploadButtonClick:) forControlEvents:UIControlEventTouchUpInside];
       [uploadButton setTag:999];
       cell.accessoryView = uploadButton;
      }
     else {
     uploadButton = (UIButton *)cell.accessoryView;
     }



     EMRAppDelegate *appDelegate = (EMRAppDelegate *)[[UIApplication sharedApplication] delegate];


   ObjectData *theCellData =[resultArray objectAtIndex:indexPath.row];

   WalkPatient * patient = [ appDelegate.walkPatients objectAtIndex:indexPath.row];

   if (indexPath.section == 0)
   {
    // do coding for cell loading for Scheduled Patients 


     cell.textLabel.font = [UIFont systemFontOfSize:18];
     cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", theCellData.firstName, theCellData.lasttName];

      if (patient.syncDate != nil) {
        UIImageView * checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]];
        [checkmark setFrame:CGRectMake(12, 0, 12, 12)];
        [checkmark setTag:998];
        [uploadButton addSubview:checkmark];
        [checkmark release];
        [uploadButton removeTarget:self action:@selector(onUploadButtonClick:) forControlEvents:UIControlEventTouchUpInside];

        NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd/MM/yyyy hh:mm"];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
        cell.detailTextLabel.text = [NSString stringWithFormat:@"Synched: %@", [dateFormatter stringFromDate:patient.syncDate]];
        [dateFormatter release];
         } 
        else {
        UIView * checkmark = (UIView *)[uploadButton viewWithTag:998];
        if (checkmark != nil) {
            [checkmark removeFromSuperview];
         }
       }

       cell.selectionStyle = UITableViewCellSelectionStyleNone;

      return cell;

       }

    else
     {
    // do load cells for    Walk In Patients. 





       cell.textLabel.font = [UIFont systemFontOfSize:18];
       cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", patient.firstName, patient.lastName];

       if (patient.syncDate != nil) {
       UIImageView * checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]];
       [checkmark setFrame:CGRectMake(12, 0, 12, 12)];
       [checkmark setTag:998];
       [uploadButton addSubview:checkmark];
       [checkmark release];
       [uploadButton removeTarget:self action:@selector(onUploadButtonClick:) forControlEvents:UIControlEventTouchUpInside];

        NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd/MM/yyyy hh:mm"];
         cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
         cell.detailTextLabel.text = [NSString stringWithFormat:@"Synched: %@", [dateFormatter stringFromDate:patient.syncDate]];
         [dateFormatter release];
      } 
      else {
        UIView * checkmark = (UIView *)[uploadButton viewWithTag:998];
        if (checkmark != nil) {
        [checkmark removeFromSuperview];
        }
      }

      cell.selectionStyle = UITableViewCellSelectionStyleNone;

       return cell;


      }
   }
  • 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-01T13:28:49+00:00Added an answer on June 1, 2026 at 1:28 pm

    Its simple. In cellForRowAtIndexPath method also you put one condition to check the section and load data according to them.

    if (indexPath.section == 0)
    {
        // do coding for cell loading for Scheduled Patients 
          UIButton *btnsection0=[UIButton buttonWithType:UIButtonTypeCustom];
          [btnsection0 addTarget:self action:@selector(showProject:) forControlEvents:UIControlEventTouchUpInside];
    
    }
    
    else
    {
         // do load cells for    Walk In Patients. 
          UIButton *btnsection1=[UIButton buttonWithType:UIButtonTypeCustom];
          [btnsection0 addTarget:self action:@selector(showProject:) forControlEvents:UIControlEventTouchUpInside];
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have a table view with some sections which have their own headers
I have a simple table view which I have built using an example from
I have X sections. I want to lazy load images in different Custom Cell
I have 2 sections, each section contains of 2 Points and each point has
I have a UITableView with two sections: free and paid. Each section has a
I have created a static table cell in a .xib, however when it is
I have criteria saved within the records of a criteria table which I'm using
I have a table with multiple rows, with each row having a button within
I have a table view which I'm using for some settings in my app.
I am using the analyse menu option from within Xcode 4.2 and I have

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.