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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:43:23+00:00 2026-05-26T17:43:23+00:00

Please see – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @SimpleTableIdentifier;

  • 0

Please see

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

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView
                         dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                  reuseIdentifier:SimpleTableIdentifier] autorelease];




UILabel *playerHeading=[[UILabel alloc ]initWithFrame:CGRectMake(5.0f, 10.0f, 70.0f, 30.0f)];
[playerHeading setBackgroundColor:[UIColor clearColor]];


NSString *str=[NSString stringWithFormat:@"Player %i",indexPath.row];
[playerHeading setText:str];
[playerHeading setFont:[UIFont boldSystemFontOfSize:15]];

if(indexPath.section%2==0){
    playerHeading.textColor=[UIColor redColor];
}
else {
    playerHeading.textColor=[UIColor blueColor];

}

UITextField *txt=[[UITextField alloc]initWithFrame:CGRectMake(80.0f, 13.0f, 170.0f, 30.0f)];
[txt setBackgroundColor:[UIColor clearColor]];


//[txt setBackgroundColor:[UIColor whiteColor]];
[txt setTextColor:[UIColor grayColor]];
txt.delegate=self;
//[txt setBorderStyle:UIBorderStyle ]
[txt setText:@"Enter Player name"];
//txt.layer.cornerRadius=8.0f;
   //   txt.layer.masksToBounds=YES;
//txt.layer.borderColor=[[UIColor redColor]CGColor];
   //   txt.layer.borderWidth= 1.0f;

[cell.contentView addSubview:txt];

[cell.contentView addSubview:playerHeading];

[cell.contentView setAlpha:0.8f];
//ce]ll.textLabel.text = [listData objectAtIndex:row];
}
return cell;

}

I want to display the number in sequence like Player 0, Player 1, Player 2…
but as I scroll the table i get numbers in random format like Player 1, Player 0 ,Player 3
Please help how to solve this issue.

  • 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-26T17:43:23+00:00Added an answer on May 26, 2026 at 5:43 pm

    You are adding the labels as new subviews all the time – this means you will have label above label above label, which is a waste of memory as well as a potential source of display issues.

    When you create your cells (inside if (cell == nil) create and add the subviews at that point, and assign each one a tag. Then configure them all outside that loop. An example just with your playerHeading label:

    UILabel *playerHeading;
    
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                  reuseIdentifier:SimpleTableIdentifier] autorelease];
        playerHeading=[[UILabel alloc ]initWithFrame:CGRectMake(5.0f, 10.0f, 70.0f, 30.0f)];
        [playerHeading setBackgroundColor:[UIColor clearColor]];
        [playerHeading setFont:[UIFont boldSystemFontOfSize:15]];
        [playerHeading setTag:1];
        [cell.contentView addSubview:playerHeading];
    }
    else
    {
        playerHeading = [cell.contentView viewWithTag:1];
    }
    
    playerHeading.text = [NSString stringWithFormat:@"Player %i",indexPath.row];
    

    You do appear to have more than one section in your table (you have an if statement on indexPath.section) so your player numbers will start again from 0 in each section with the above code.

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

Sidebar

Related Questions

Please see following methods. public static ProductsCollection GetDummyData(int? customerId, int? supplierId) { try {
Please see this image for what I'm referring to as a static box: I'm
Please see the following code: NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@test.pdf]; NSData *myData = [NSData
Please see code below. The destructors are never called. Anyone know why and how
Please see here for a related question . However, char goes to 0xffff (or
Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i
Please see MSO question A long list of possible duplicates — C memory allocation
Please see the code below: #include <iostream> #include <stdlib.h> #include <time.h> using namespace std;
Important : Please see this very much related question: Return multiple values in C++
everyone. Please see example below. I'd like to supply a string to 'schedule_action' method

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.