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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:19:45+00:00 2026-05-23T21:19:45+00:00

if (indexPath.row % 2 == 0) { // EVEN cell = [tableView dequeueReusableCellWithIdentifier:@EvenCell]; if

  • 0
 if (indexPath.row % 2 == 0) {
    // EVEN
    cell = [tableView dequeueReusableCellWithIdentifier:@"EvenCell"];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EvenCell"] autorelease];
        UIView *bg = [[UIView alloc] initWithFrame:cell.frame];

        UIColor *colour = [[UIColor alloc] initWithRed: (208.0/255.f) green: (231.0/255.f) 
                                                  blue: (241.0/255.f) alpha: 1.0];
        bg.backgroundColor = colour; 
        cell.backgroundView = bg;
        cell.textLabel.backgroundColor = bg.backgroundColor;
        [bg release];
        cell.textLabel.text = [items objectAtIndex:indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

} else {
    // ODD

    cell = [tableView dequeueReusableCellWithIdentifier:@"OddCell"];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"OddCell"] autorelease];
        UIView *bg = [[UIView alloc] initWithFrame:cell.frame];

        UIColor *colour = [[UIColor alloc] initWithRed: (143.0/255.f) green: (169.0/255.f) 
                                                  blue: (180.0/255.f) alpha: 1.0];
        bg.backgroundColor = colour;
        cell.backgroundView = bg;
        cell.textLabel.backgroundColor = bg.backgroundColor;
        [bg release];
        cell.textLabel.text = [items objectAtIndex:indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
} 

return cell;
}

this is my custom cells.first one is even second one is odd’s.My array has 194 elements but when i run the application i can only see 10 after the 10th one it goes to first element again give me same 10 elements.Can anybody tell me what is wrong in here?

  • 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-23T21:19:46+00:00Added an answer on May 23, 2026 at 9:19 pm

    Try this.

    if (indexPath.row % 2 == 0) {
    // EVEN
            cell = [tableView dequeueReusableCellWithIdentifier:@"EvenCell"];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EvenCell"] autorelease];
                UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
    
    
            UIColor *colour = [[UIColor alloc] initWithRed: (208.0/255.f) green: (231.0/255.f) 
                                                      blue: (241.0/255.f) alpha: 1.0];
            bg.backgroundColor = colour; 
            cell.backgroundView = bg;
            cell.textLabel.backgroundColor = bg.backgroundColor;
            [bg release];
        }
            cell.textLabel.text = [items objectAtIndex:indexPath.row];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    
    } else {
        // ODD
    
        cell = [tableView dequeueReusableCellWithIdentifier:@"OddCell"];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"OddCell"] autorelease];
            UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
    
            UIColor *colour = [[UIColor alloc] initWithRed: (143.0/255.f) green: (169.0/255.f) 
                                                      blue: (180.0/255.f) alpha: 1.0];
            bg.backgroundColor = colour;
            cell.backgroundView = bg;
            cell.textLabel.backgroundColor = bg.backgroundColor;
            [bg release];
        }
            cell.textLabel.text = [items objectAtIndex:indexPath.row];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    
      } 
    
      return cell;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (cell.accessoryType
I was calling UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; from -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath in
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; in this method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; but I
The following leaks: CFStringRef labelName = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(aMultiRef, indexPath.row)); cell.textLabel.text = (NSString *)labelName; CFRelease(labelName); Wondering
I have the following Objective-c Function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger
this code works fine until I start scrolling: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I have this code: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { [array removeObjectAtIndex:indexPath.row]; if
I am having code NSString *cellValue1 = [products1 objectAtIndex:indexPath.row]; when i try to print
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if([tableView.somethingMagicalHereThatAllowsMeKnowWhichCellItIs isEqualToString:@CellType]){ return 50; } return 25;} I
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MaSystemGuiAppDelegate *appDelegate = (MaSystemGuiAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.deneme

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.