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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:07:50+00:00 2026-05-29T07:07:50+00:00

I have the following method that loads cells into my table. The cell with

  • 0

I have the following method that loads cells into my table. The cell with text “No Results” is being repeated though as I scroll. What am I doing wrong with the dequeueing?

    - (UITableViewCell *)tableView:(UITableView *)iTableView cellForRowAtIndexPath:(NSIndexPath *)iIndexPath {
    static NSString *kCellID = @"cellID";

    UITableViewCell *aCell = [iTableView dequeueReusableCellWithIdentifier:kCellID];
    if (aCell == nil) {
        aCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kCellID] autorelease];
    }

    if (iTableView == self.searchDisplayController.searchResultsTableView) {
        if (self.isSearching) {
            static NSString *aProgressIdentifier = @"SearchProgress";
            aCell = [iTableView dequeueReusableCellWithIdentifier:aProgressIdentifier];
            if (!aCell) {
                aCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:aProgressIdentifier] autorelease];
            }

            aCell.userInteractionEnabled = NO;
            UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectZero];
            aLabel.text = @"Searching...";
            aLabel.font = [UIFont systemFontOfSize:16.0f];
            aLabel.textColor = [UIColor grayColor];
            aLabel.textAlignment = UITextAlignmentCenter;
            [aLabel sizeToFit];
            aLabel.frame = CGRectMake(floorf((self.view.frame.size.width / 2.0f) - (aLabel.frame.size.width / 2.0f)), floorf((aCell.frame.size.height / 2.0f) - (aLabel.frame.size.height / 2.0f)), aLabel.frame.size.width, aLabel.frame.size.height);
            [aCell addSubview:aLabel];
            [aLabel release];

            UIActivityIndicatorView *aSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
            [aCell addSubview:aSpinner];
            aSpinner.frame = CGRectMake(floorf((aCell.frame.size.width / 2.0f) - (aSpinner.frame.size.width / 2.0f)) - floorf(aLabel.frame.size.width / 2.0f) - 20.0f, floorf((aCell.frame.size.height / 2.0f) - (aSpinner.frame.size.height / 2.0f)), aSpinner.frame.size.width, aSpinner.frame.size.height);
            [aSpinner startAnimating];
            [aSpinner release];
        } else {
            Class anObject = [self.masterArray objectAtIndex:iIndexPath.section];
            if ([anObject isKindOfClass: [NSArray class]]) {
                NSArray *sectionArray = [self.masterArray objectAtIndex:iIndexPath.section];
                if (sectionArray.count > 0) {
                    id aCellObject = [sectionArray objectAtIndex:iIndexPath.row];
                    if ([aCellObject isKindOfClass:[CMACustomer class]]) {
                        CMACustomer *aCustomerObject = aCellObject;
                        aCell.textLabel.
                        text = aCustomerObject.customerFullName;
                        aCell.detailTextLabel.text = nil;                
                    } else if ([aCellObject isKindOfClass:[CMAReservation class]]) {
                        CMAReservation *aReservationObject = aCellObject;
                        aCell.textLabel.text = aReservationObject.fullName;
                        aCell.detailTextLabel.text = aReservationObject.orderDescription;     
//                        aCell.detailTextLabel.text = aReservationObject.reservationTimeAndDate;                
                    } 
                } else {
                    aCell.userInteractionEnabled = NO;
                    UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectZero];
                    aLabel.text = @"No Results.";
                    aLabel.font = [UIFont systemFontOfSize:16.0f];
                    aLabel.textColor = [UIColor grayColor];
                    aLabel.textAlignment = UITextAlignmentCenter;
                    [aLabel sizeToFit];
                    aLabel.frame = CGRectMake(floorf((self.view.frame.size.width / 2.0f) - (aLabel.frame.size.width / 2.0f)), floorf((aCell.frame.size.height / 2.0f) - (aLabel.frame.size.height / 2.0f)), aLabel.frame.size.width, aLabel.frame.size.height);
                    [aCell addSubview:aLabel];
                    [aLabel release];
                }
            }
        }
    } else {
        NSString *aLocalizedTitle = [[self.defaultScopeArray objectAtIndex:iIndexPath.row] objectForKey:@"localizedTitle"];
        NSString *aDefaultTitle = [[self.defaultScopeArray objectAtIndex:iIndexPath.row] objectForKey:@"defaultTitle"];
        aCell.textLabel.text = CMALocalizedStringWithDefaultValue(aLocalizedTitle, aDefaultTitle);

        if ([[[self.currentScopeArray objectAtIndex:iIndexPath.row] objectForKey:@"enabledByDefault"] boolValue]) {
            aCell.accessoryType = UITableViewCellAccessoryCheckmark;
        } else {
            aCell.accessoryType = UITableViewCellAccessoryNone;
        }
    }
    return aCell;
}
  • 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-29T07:07:51+00:00Added an answer on May 29, 2026 at 7:07 am

    A couple of things:

    1. If you just want text labels in your cells there is no need to add a UILabel to the tableViewCell. Just use the textLabel property of the cell or the detailTextLabel property (depending on the tableviewcell type you’re using).

    2. If you do want to add a UILabel you should add it to the contentView property of the tableViewCell.

    3. When you are adding views to a tableViewcell, you really shouldn’t alloc/init it outside of the if(!Cell) {} block as every time you’re recycling that tableViewcell, another another UILabel is alloc/init‘d.

    4. According to the code you posted and the problem you are seeing, it looks like sectionArrayis empty. Where is that being filled?

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

Sidebar

Related Questions

The following method loads data from an array into custom cells of UITableView. The
I have the following method that is replacing a pound sign from the file
I have the following method that is supposed to be a generic Save to
I have a method that contains the following (Java) code: doSomeThings(); doSomeOtherThings(); doSomeThings() creates
I have a method that I will use in the following contexts: 1. User
I have a partial that renders a select box using the following method: <%=
I have a program that makes use of the following method to get a
In Python compiled regex patterns have a findall method that does the following: Return
I have a simple mapview that has the following viewdidload method and didupdate to
I have a function with the following code that binds a table dynamically. I

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.