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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:46:02+00:00 2026-05-12T23:46:02+00:00

I have 5 seperate sections in a table, 2 of the sections have customizable

  • 0

I have 5 seperate sections in a table, 2 of the sections have customizable cells, when in EDITING mode, 2 of the sections produce an additional cell that will add a new cell to the list. My problem is that when I invoke edit mode, the UISwitch glitches! and decides to jump around, VERY SIMPLE code, just have NO IDEA why the UISwitch is jumping to different cells in DIFFERENT SECTIONS when it should NOT!

static NSInteger kCustomTextTag = 1;
static NSInteger kServiceTag = 3;
static NSInteger kConnectTag = 4;
static NSInteger kVibrateTag = 1;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{    
    Profile_ManagerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        cell.hidesAccessoryWhenEditing = YES;
    }

    UISwitch *swService = nil;
    swService = [[[UISwitch alloc] initWithFrame:CGRectMake(195, 8, 160, 27)] autorelease];
    [swService addTarget:self action:@selector(serviceSwAction:) forControlEvents:UIControlEventValueChanged];
    swService.tag = kServiceTag;

    UISwitch *swConnect = nil;
    swConnect = [[[UISwitch alloc] initWithFrame:CGRectMake(195, 8, 160, 27)] autorelease];
    [swConnect addTarget:self action:@selector(connectSwAction:) forControlEvents:UIControlEventValueChanged];
    swConnect.tag = kConnectTag;

    UISwitch *swVibrate = nil;
    swVibrate = [[[UISwitch alloc] initWithFrame:CGRectMake(195, 8, 160, 27)] autorelease];
    [swVibrate addTarget:self action:@selector(vibrateSwAction:) forControlEvents:UIControlEventValueChanged];
    swVibrate.tag = kVibrateTag;

    if(indexPath.section == 0)
    {
        //CGRectMake Method (x, y, width, height)
        custProfileNameLabel = [[[UITextField alloc] initWithFrame:CGRectMake(10, 11, 290, 21)] autorelease];
        custProfileNameLabel.tag = kCustomTextTag;
        custProfileNameLabel.textAlignment = UITextAlignmentLeft;
        [cell.contentView addSubview:custProfileNameLabel];
        custProfileNameLabel.backgroundColor = [UIColor clearColor];
        custProfileNameLabel.userInteractionEnabled = NO;
        custProfileNameLabel.placeholder = @"Custom Profile Name";
        custProfileNameLabel.autocapitalizationType = UITextAutocapitalizationTypeWords;
        custProfileNameLabel.clearButtonMode = UITextFieldViewModeWhileEditing;

        //UIKeyboardTypeDefault;
        cell.selectionStyle = UITableViewCellEditingStyleNone;
        CustomProfile *cProf = [CustomProfile alloc];
        cell.textLabel.text = [cProf tName];
    }

    if(indexPath.section == 1)
    {
        if(indexPath.row == ([[appDelegate serviceArray] count]) && self.editing){
            cell.textLabel.text = @"Add a Service";
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
            swService.hidden = YES;
            return cell;
        }else{
            swService.hidden = NO;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.textLabel.text = [[appDelegate serviceArray] objectAtIndex:indexPath.row];
        }
        [cell addSubview:swService];
    }

    if(indexPath.section == 2)
    {
        if(indexPath.row == ([[appDelegate connectArray] count]) && self.editing){
            cell.textLabel.text = @"Add a Connection";
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
            swConnect.hidden = YES;
            return cell;
        }else{
            swConnect.hidden = NO;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.textLabel.text = [[appDelegate connectArray] objectAtIndex:indexPath.row];
        }
        [cell addSubview:swConnect];
    }

    if(indexPath.section == 3)
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
        NSString *documentsDirectory = [paths objectAtIndex:0]; 
        NSString *myPlistPath = [documentsDirectory stringByAppendingPathComponent:@"ProfileManager.plist"]; 
        NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:myPlistPath]; 

        NSString *value;
        value = [plistDict objectForKey:@"Custom Ringtone"];

        if(indexPath.row == ([[appDelegate ringArray] count]) && self.editing){
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
        }else{
            cell.selectionStyle = UITableViewCellSelectionStyleBlue;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }

        cell.textLabel.text = value;
    }

    if(indexPath.section == 4)
    {
        if(indexPath.row == 0 && self.editing)
        {
            //cell.userInteractionEnabled = NO;
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.textLabel.text = @"Vibrate";
            swVibrate.hidden = YES;
        }else{
            swVibrate.hidden = NO;
            //cell.accessoryType = UITableViewCellAccessoryNone;    
            cell.selectionStyle = UITableViewCellSelectionStyleBlue;
            cell.textLabel.text = @"Vibrate";
        }   

        [cell.contentView addSubview:swVibrate];
    }

    return cell;
}   

Screenshot

enter image description 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-12T23:46:03+00:00Added an answer on May 12, 2026 at 11:46 pm

    Well, the reason this glitch was made possible is because the Controls were created when creating the cell, so it just continued to create additional controls when view appeared.

    If you are receiving this glitch too, make sure you create the controls at ViewDidLoad, or call a void, just dont create the controls in the cellForRowAtIndexPath:

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

Sidebar

Related Questions

I have a table that will rebuild async every time a new option is
I have a UINavigationController and I have seperate UIViews that I switch between using
Suppose you have two seperate ASP.NET Web Application projects that both need to use
I have a list of class items List<MyClass> I have a seperate object that
I have 2 functions on a seperate page that I am including of the
I have a python program that opens several urls in seperate tabs in a
I have a table which needs to link one of three seperate tables, but
On a HTML page I have three sections with 3 tables. Each table has
I have 9 sections in my table (they get pulled from an array). In
I have a Table that is generated using a SQL Database And put into

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.