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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:03:37+00:00 2026-05-30T01:03:37+00:00

The below code works fine when i am not adding any extra row all

  • 0

The below code works fine when i am not adding any extra row all the content view are controlled(hide/visible) but problem when adding to dummy rows.
i am having a table view created programatically.i am initializing my cell with some content view(labels & buttons).I am adding two dummy rows as : if indexPath.row > [mYarray count].I am trying to hide my buttons in extra added rows.BUt when i’m scrolling the buttons are some times hiding from cell or some time displaying in cell.The condition is something like: if(indexPath.row < [mYarray count]) then buttons MAY(See below code,the condition which decides to hide/visible if(ShowNQButton)) be hide/visible.But if(indexPath.row > [mYarray count]) then buttons MUST be hide/invisible/removed.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];



    if (cell == nil) 
    {

        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Identifier] autorelease];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;      

        waitTimeLabel=[[[UILabel alloc] initWithFrame:CGRectMake(210, 0, 50, 30)]autorelease];
        waitTimeLabel.backgroundColor=[UIColor clearColor];
        waitTimeLabel.tag=lblTAG5;
        waitTimeLabel.numberOfLines=2;
        waitTimeLabel.font=[UIFont systemFontOfSize:13];
        [cell.contentView addSubview:waitTimeLabel];

        EstSeatLabel=[[[UILabel alloc] initWithFrame:CGRectMake(270, 0, 60, 30)]autorelease];
        EstSeatLabel.backgroundColor=[UIColor clearColor];
        EstSeatLabel.tag=lblTAG6;
        EstSeatLabel.font=[UIFont systemFontOfSize:12];
        [cell.contentView addSubview:EstSeatLabel];

    }
    else
    {   

        waitTimeLabel=(UILabel *)[cell viewWithTag:lblTAG5]; 
        EstSeatLabel=(UILabel *)[cell viewWithTag:lblTAG6];         

    } 
if (indexPath.row < [UIAppDelegate.waitlistDetailArray count]) {


        NQbutton =   [[UIButton alloc]init];
        NQbutton.frame=CGRectMake(220, 4, 42, 24);
        NQbutton.adjustsImageWhenHighlighted=NO;
        NQbutton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        NQbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

        UIImage *NQbuttonimage = [UIImage imageNamed:@"NqN"];
        [NQbutton setBackgroundImage:NQbuttonimage forState:UIControlStateNormal];
        [NQbutton addTarget:self action:@selector(NQbutton:event:) forControlEvents:UIControlEventTouchUpInside];

        NQbutton.backgroundColor = [UIColor clearColor];
        [cell.contentView addSubview:NQbutton];
        [NQbutton release];

        NQbuttonEstTime=   [[UIButton alloc]init];
        NQbuttonEstTime.frame=CGRectMake(275, 4, 42, 24);
        NQbuttonEstTime.adjustsImageWhenHighlighted=NO;
        NQbuttonEstTime.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        NQbuttonEstTime.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

        UIImage *NQbuttonesttimeimage = [UIImage imageNamed:@"NqN"];
        [NQbuttonEstTime setBackgroundImage:NQbuttonesttimeimage forState:UIControlStateNormal];
        [NQbuttonEstTime addTarget:self action:@selector(NQbutton:event:) forControlEvents:UIControlEventTouchUpInside];

        NQbuttonEstTime.backgroundColor = [UIColor clearColor];
        [cell.contentView addSubview:NQbuttonEstTime];      
        [NQbuttonEstTime release];

        if(ShowNQButton)//**this BOOL variable is outside of cellForRow decides if buttons  //should be visible or not when indexPath.row < myArray' count.**
        {
            NQbutton.hidden=NO;
            NQbuttonEstTime.hidden=NO;

        }
        else {
            NQbutton.hidden=YES;
            NQbuttonEstTime.hidden=YES;

        }


    } 
else
    {//i have added three dummy rows in numberOfRowsInSection(when indexpath.row > [myArray Count])
        waitTimeLabel.text=@" "; 
    EstSeatLabel.text=@" ";

        //below i am stuffing in removing/hiding these two contentViews from dummy cells 
        NQbutton.hidden=YES;//tried setImage=nil fornormalState//tried removeFromSupViw
        NQbuttonEstTime.hidden=YES;//tried setImage=nil fornormalState//tried removeFromSupViw
    }


}


return cell;

}

Any suggestions?
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-30T01:03:38+00:00Added an answer on May 30, 2026 at 1:03 am

    The problem is with the dequeue cell. If you look your code, you are adding the two buttons only on the indexPath.row<[array cont] Logically its correct.
    So try with solution provided here

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

Sidebar

Related Questions

Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
HI all, Below mentioned javascript code works fine in all browsers including chrome(from second
The below code works fine on IE7 but not in Safari(5.0.5). If possible, I
Below code works fine in Firefox, but not in IE8. It triggers mouse click
My below code works fine and is used to populate a <select> item with
the code below works fine but it takes an absolute age to run. How
Currently my code below works fine but it's a bit of overkill. In my
I have the code below, which works fine it can be viewed for an
The code below is the code i am using. It works fine in thunderbird
I have a really weird problem. The below code works fine if I create

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.