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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:25:59+00:00 2026-06-06T17:25:59+00:00

I am creating a TableView which contains 20 rows.I have to add single labels

  • 0

I am creating a TableView which contains 20 rows.I have to add single labels to the even cells and i have to add two labels at odd cells.When i adding the desired labels and scrolling my table the labels disappars as i go down help me out.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // UITableView *cell=[tableView ]
if (cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if(indexPath.row%2==0)
    {
        UILabel *cellLabel=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)]; 
        cellLabel.text=@"o1";
        [cell addSubview:cellLabel];
        [cellLabel release];
    }
    else
    {
        UILabel *cellLabel1=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)]; 
        cellLabel1.text=@"e1";
        [cell addSubview:cellLabel1]; 
        [cellLabel1 release];
        UILabel *cellLabel2=[[UILabel alloc]initWithFrame:CGRectMake(150, 40, 40, 40)]; 
        cellLabel2.text=@"e2";
        [cell addSubview:cellLabel2]; 
        [cellLabel2 release];
    }

}
  • 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-06T17:26:00+00:00Added an answer on June 6, 2026 at 5:26 pm

    The two kinds of cells are different, so I would make different cell identifiers for each. Something like:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *EvenCellIdentifier = @"EvenCell";
        static NSString *OddCellIdentifier = @"OddCell";
        NSString* cellIdentifier = (indexPath.row % 2) == 0 ? EvenCellIdentifier : OddCellIdentifier;
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
    
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            if(indexPath.row%2==0) 
            {
                UILabel *cellLabel=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)]; 
                cellLabel.text=@"o1";
                [cell addSubview:cellLabel];
                [cellLabel release];
            }
            else
            {
                UILabel *cellLabel1=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)]; 
                cellLabel1.text=@"e1";
                [cell addSubview:cellLabel1]; 
                [cellLabel1 release];
                UILabel *cellLabel2=[[UILabel alloc]initWithFrame:CGRectMake(150, 40, 40, 40)]; 
                cellLabel2.text=@"e2";
                [cell addSubview:cellLabel2]; 
                [cellLabel2 release];
            }
        }
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating UIView on top of tableview in which there will an imageview
I have a uitableview 'A' which has cells, on clicking one of the cell,
I am creating an application in which I have to divide a cell into
I have a tableView with sections, which could be opened and closed. So, when
I am creating an app in which i have a UITableView and the table
I am creating a Mac application in which I have mainwindow with some buttons.
I am programmatically creating a tableview in objective c. How can I make the
I am creating a favorite pages menu in my tableview application, where users can
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I am creating one sample application in which i am reading database and displaying

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.