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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:20:39+00:00 2026-06-11T22:20:39+00:00

I am trying to implement the table view with 4 cells in each section

  • 0

I am trying to implement the table view with 4 cells in each section and number of section is also 2. I added the buy button in last two rows of each sections and make them hidden till row is not selected. When I click on last row of the first section, the buy button appears. However, as soon as I tap on last row of second section (last section) than it do not appears. Here is my code.

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

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) 
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
    reuseIdentifier:CellIdentifier];

// some code for cell properties

    if(indexPath.section==0)
    {   
      if(indexPath.row==2)
        {                
            //some code for property of buy button1

            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.accessoryView = buyButton1;
            [buyButton1 setHidden:YES];
        }
      if(indexPath.row==3)
        {                              
          //some code for property of buy button2
          cell.accessoryType = UITableViewCellAccessoryNone;
          cell.accessoryView = buyButton2;
          [buyButton2 setHidden:YES];
        }
    }    

    if(indexPath.section==1)
    {   
       if(indexPath.row==2)
        {

            //some code for property of buy button3
            [cell addSubview:buyButton3];
            [buyButton3 setHidden:TRUE];

        }
        if(indexPath.row==3)
        {

            buyButton4= [UIButton buttonWithType:UIButtonTypeRoundedRect];
            buyButton4.frame = CGRectMake(194, 4, 70, 37);
            [buyButton4 setTitle:@"Buy" forState:UIControlStateNormal];

            [buyButton4 addTarget:self action:@selector(buyButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
            buyButton4.tag = 4;
            [cell addSubview:buyButton4];
            [buyButton4 setHidden:TRUE];

        }
    } 

}
if(indexPath.section == 0)
{
  cell.textLabel.text = [privateArray objectAtIndex:indexPath.row];
}    
else
{
  cell.textLabel.text = [workArray objectAtIndex:indexPath.row];

}
return cell;
}

Here is my code for selection of row

- (void)tableView:(UITableView *)tableview didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{

[tableViewForOccasion deselectRowAtIndexPath:indexPath animated:NO];

NSArray *visibleCells = [tableViewForOccasion visibleCells];

for (UITableViewCell *aCell in visibleCells) 
{
    aCell.accessoryType = UITableViewCellAccessoryNone;
}
if(indexPath.section==1)
{
  if(indexPath.row==3)
   {
     [buyButton4 setHidden:FALSE];
   }
}
}

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-06-11T22:20:40+00:00Added an answer on June 11, 2026 at 10:20 pm

    since you are talking about the last row in the second section then your checking condition is wrong

    if(indexPath.section==1)
    {
      if(indexPath.row==3) // you have mistake in this part where you had if(indexPath.row==2)
       {
         [buyButton4 setHidden:FALSE];
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a table view which should display cells according to the
I'm currently trying to implement a Table View on my iPhone app that grabs
I'm trying to implement a segue from one a table view controller to another
I am trying to implement a table that is sortable on more than one
For a game, I am trying to implement a scores table. According to game
I’m trying to implement a simple fixed headers table. I know this can in
I'm trying to make a table view with an appearance much like the default
I'm trying to implement a UIScrollView in each cell of `UITableView'. I wrote my
I am trying to implement an editable table viewer in Eclipse SWT. I think
I'm trying to implement a twitter iPhone app like interface. (Swipe to replace view

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.