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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:40:22+00:00 2026-06-03T01:40:22+00:00

I have implemented a tableview with a custom cell. 1.Custom cell Custom cell having

  • 0

I have implemented a tableview with a custom cell.

1.Custom cell
enter image description here

Custom cell having a label to display date and an UI Switch to set alarms.

My table view appears like like this when we switch on the uiswitches,
enter image description here

2.Table view

When user scrolls down the table view the bottom switches are turned off

enter image description here

Same problem when scrolls up.

enter image description here

why this problem happens ? and how to prevent it?

Cell for row at index path method

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Note: I set the cell's Identifier property in Interface Builder to DemoTableViewCell.
    static NSString *CellIdentifier = @"Cell";

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

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    //To display custom cell with label and switch
    if(indexPath.row< [appDelegate.alarmsArray count])
    {
        ReminderCell *cell = (ReminderCell *)[tableView dequeueReusableCellWithIdentifier:CellClassName];
        if (!cell)
        {
            NSArray *topLevelItems = [cellLoader instantiateWithOwner:self options:nil];
            cell = [topLevelItems objectAtIndex:0];
        }

        cell.reminderSwitch.tag = indexPath.row;

        NSMutableDictionary *dict = [appDelegate.alarmsArray objectAtIndex:indexPath.row];
        cell.label.text = [dict objectForKey:@"string"];
//=========================================
        cell.reminderSwitch.on = NO;
//=========================================
        return cell;
    }


    //Add + button on the last row of uitableview cell..
    if(indexPath.row == [appDelegate.alarmsArray count])
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
        button.frame = CGRectMake(114, 9.5, 33, 33); 
        [button addTarget:self action:@selector(AddNewRow:) forControlEvents:UIControlEventTouchUpInside]; 
        [cell.contentView addSubview:button ];
        return cell;
    }

    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-06-03T01:40:24+00:00Added an answer on June 3, 2026 at 1:40 am
    In CustomCell Class Write function like this 
    
    -(void)SetSwitchStatus:(NSInteger )stat
    {
        if(stat == 0)
          //Set Switch off
        else
        //Set Switch on
    } 
    
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        StoresCustomCell *cell =(StoresCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) 
        {
            [[NSBundle mainBundle] loadNibNamed:@"StoresCustomCell" owner:self options:nil];
            cell = StoreCell;
        }
        [cell SetSwitchStatus:[StatusArr objectAtIndex:indexPath.row];
    }
    
    In ViewdidLoad Function Set 0 elements to all statusArr,,  StatusArr count = TableView rows Count
    
    - (void)tableView:(UITableView *)sender didSelectRowAtIndexPath:(NSIndexPath *)path {
    
    if([[StatusArr objectAtIndex:path.row] isEqualToString:@"0"])
       [StatusArr replaceObjectAtIndex:path.row withObject:@"1"]
    else
       [StatusArr replaceObjectAtIndex:path.row withObject:@"0"]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a custom table view cell. I can get the cell to
I have custom table view cell with images (loaded from app document directory), labels,
I have a table view of custom cells representing individual uploads and each cell
So, I have implemented this method to add a footer to my table view:
I have a UITextField in a custom tableview cell. On tapping the textfield area
I have implemented a custom ActionMapper which obtains the locale from the URI (the
I have implemented a file transfer rate calculator to display kB/sec for an upload
In cellForRowAtIndexPath: method I have implemented gesture recognizer for long press, -(UITableViewCell *)tableView:(UITableView *)tableView
I have a view which consists of a tableview and a navigation bar. For
I have a UITableView with custom UITableViewCells. The table has two sections, the first

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.