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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:40:45+00:00 2026-05-16T05:40:45+00:00

I am working on UITableView. I have added a table in my view programmatically

  • 0

I am working on UITableView. I have added a table in my view programmatically and populated it with some data by adding UILable as a subview of each cell. Table has 21 rows. Problem is that when i scroll up or down, the data in the first two rows and last 2 or 3 rows is overlapped with some other row’s data. For example first two bowlers data is over lapped with first two batsmen data. Task is to first show a list of batsman then leave 2 cells empty and then show a list of bowlers in the same table. My code is

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];     
if (cell == nil) {         
  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];     
}          
NSString *string1;     
NSString *string2;               
  if(indexPath.row < [inningObject.battingLine count]){
    Batter *cBatter = [inningObject.battingLine objectAtIndex:indexPath.row];         
    string1 = cBatter.batterName;         
    string2 = cBatter.runs;         
  }else if(indexPath.row > [inningObject.battingLine count]+1){
    Bowler *cBowler = [inningObject.bowlingLine objectAtIndex: indexPath.row-[inningObject.battingLine count]-2]; // start from zero for next NSArray
    string1 = cBowler.bowlerName;
    string2 = cBowler.wickets;         
  }          
  CGRect a=CGRectMake(5, 0, 320, 38);     
  if(indexPath.row < [inningObject.battingLine count] || indexPath.row >= [inningObject.battingLine count]+2){          
    CGRect string1Rect = CGRectMake(5, 10, 150, 18);
    UILabel *string1Label = [[UILabel alloc] initWithFrame:string1Rect]; 
    string1Label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];      
    string1Label.textAlignment = UITextAlignmentLeft;
    string1Label.text = string1;
    string1Label.font = [UIFont boldSystemFontOfSize:17];
    [cell.contentView addSubview: string1Label];
    [string1Label release];
    CGRect string2Rect = CGRectMake(240, 10, 70, 18);
    UILabel *string2Label = [[UILabel alloc] initWithFrame:string2Rect];         
    string2Label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
    string2Label.textAlignment = UITextAlignmentLeft;
    string2Label.text = string2;
    string2Label.font = [UIFont boldSystemFontOfSize:17]; 
    [cell.contentView addSubview: string2Label];
    [string2Label release];     
  }
return cell; 
}
  • 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-16T05:40:45+00:00Added an answer on May 16, 2026 at 5:40 am

    You see the problem is you are using the same CellIdentifier for two different types of data. Two ways you could deal with this:

    1.Create two different cell identifiers for the 2 different kinds of data i.e.

    CellIdentifier = @"Bowlers Cell";//for bowlers
    

    and

    CellIdentifier = @"Batters Cell";//for batters
    

    2.The approach you are using of having 2 cells empty for bowlers isnt the best. You could instead have big cell and fit in 4 subviews in it 2 for bowlers, 2 for the batters.

    I’d recommend going with option 2.

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

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could simply creat a business logic layer assembly that… May 16, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer from what i understood, i can give you this answer..… May 16, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer Sounds like the objects you are passing to Silverlight, via… May 16, 2026 at 2:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have added a UITableView in IB and set the delegate and datasource and
I want to create a landscape view with 2 table views side by side,
I've added a UITableView component to a ViewController in Interface Builder to make it
I have a core data recipe object that contains an ordered list of ingredient
Say I have two UIViewControllers , all working under a UINavigationController : RootViewController hosts
I have an application that works some what similar to how iPhone's Contact application
I have a problem that I had working in a test but now in
I am trying to update my UITableView and the following implementation is not working.
I working with some ajax at the moment, the result of a successful ajax
I have stored the videos and the thumbnail images of the videos in Documents

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.