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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:36:36+00:00 2026-06-06T11:36:36+00:00

I am currently having a problem with a UITableView, and more precisely with a

  • 0

I am currently having a problem with a UITableView, and more precisely with a Custom Cell.

I got a table view controller, let’s say ControllerA, which is in charge of displaying different TableViewCells. These cells are custom cells, defined in another class, let’s say ControllerCell. Each cell contains one of these info buttons (small, round with “i”). These buttons are only displayed when there’s something to show.

In ControllerCell, I define what’s next :

@property (nonatomic, retain) IBOutlet UIButton *infoButton;
@property (nonatomic, retain) IBOutlet UIAlertView *alert;
@property (nonatomic, retain) IBOutlet NSString *info;
- (IBAction)infoSupButton:(id)sender;

as well as the @synthesis, just like everybody would do that. Then I define what’s going to happen with the alert :

- (IBAction)infoSupButton:(id)sender {
        alert = [[UIAlertView alloc] initWithTitle:@"Informations supplémentaires" 
                                                    message:info
                                                   delegate:self 
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
       if (info != nil) {
      [alert show];
      }
}

And in the “initWithStyle” section, I do

[_infoButton addTarget:self action:@selector(infoSupButton:) forControlEvents:UIControlEventTouchUpInside];

That was for the declaration of the cell.

Now let’s focus on ControllerA.

I’m parsing a XML file to get the “info” data, which should be displayed when one clicks on the “infoButton”. This is not really a problem, because I can get this data and show it in the console.

Once the data is parsed, i fill a NSMutableArray, in the viewDidLoad section :

tableInfoSup = [[NSMutableArray alloc] init];

Then follow the classic methods :

-numberOfSectionsInTableView: (3 sections)
-numberOfRowsInSection: (8 rows in section 0, 4 in section 1 and 4 in section 2)
-cellForRowAtIndexPath:

I got 3 different sections, displaying cells with different information, and in the cellForRowAtIndex method, I do :

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

static NSString *cellIdentifier = @"ExerciceTableCell";
ControllerCell *cell = (ControllerCell *)[tableView dequeueReusableCellWithIdentifier:exerciceTableIdentifier];

if (cell == nil) 
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ExerciceTableCell" owner:self options:nil];
    cell = [nib objectAtIndex:0];

} 


if (indexPath.section == 0) {
    [...]


    if ([[tableInfoSup objectAtIndex:indexPath.row] isEqualToString:@""]) {
        [cell.infoButton setHidden:YES];
        cell.info = nil;
    }
    else {
        cell.info = [tableInfoSup objectAtIndex:indexPath.row];
    }

}
if (indexPath.section == 1) {
    [...]

    if ([[tableInfoSup objectAtIndex:indexPath.row+8] isEqualToString:@""]) {
        [cell.infoButton setHidden:YES];
        cell.info = nil;
    }
    else {
        cell.info = [tableInfoSup objectAtIndex:indexPath.row+8]; //got the 8 rows from section 0;
    }

}
if (indexPath.section == 2) {

    [...]

    if ([[tableInfoSup objectAtIndex:indexPath.row+12] isEqualToString:@""]) {
        [cell.infoButton setHidden:YES];
        cell.info = nil;
    }
    else {
        cell.info = [tableInfoSup objectAtIndex:indexPath.row+12];  //got the 8 rows from section 0, + 4 rows from section 1
    }    
}


return cell;
}

Now, the problem is that, when the screen is displayed for the 1st time, everything is in oder : I got cells with the small “i” button, displaying the good UIAlertView, some other cells do not display the button…That’s normal. But after several scrollings, the “i” buttons start to disappear….I don’t know why.

Has anybody an idea?
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-06-06T11:36:39+00:00Added an answer on June 6, 2026 at 11:36 am

    In your tableView:cellForRowAtIndexPath:, you hide the info when you don’t want it to be shown, but you don’t explicitly unhide it for cells where it should be shown.

    Look at the first two lines in that method: What you are – correctly – doing is reusing your cells, so when cells are scrolled out of view, they are removed from the UITableView and put into the reuse queue. Then, when cells should become visible, the TableView gets cells from that queue – or creates new ones if none are available.

    This all goes very well, but after a while, cells with hidden info buttons are put on the queue. And then, some time later, those cells are reused – and sometimes for rows in which there should be info visible.

    There are two solutions to this: You could either explicitly unhide the information for those rows where you want it to be shown, or you could use two different kinds of cell, one with hidden info, and one with visible info. You then give each of those cells a different identifier, and based on what row the cells are in, set the identifier before dequeuing/creating cells.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with UITableView, populated via Core Data. The table view is
The table I'm having problem with is pushed from another table controller, and there
i am having problem with setting the noOfRowsInSection in table view when displaying the
I'm having a problem. I have a Custom UITableViewCel, the cell contains a slider
I am having a problem with a table and showing another view when the
I'm currently having a problem. I need to update Table A from Table B
I'm currently having a of problem with my Phonegap application on Playbook. It consists
I am currently having a problem selecting a certain item from a mySQL database.
I'm currently having a problem with what seems like the Timer_Tick event interfering with
I am currently having the problem that I have a (partial) program that is

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.