Note that there are some explanatory texts on larger screens.

plurals
  1. POtableviews cells are changing after scrolling down
    primarykey
    data
    text
    <p>I am making a form within a grouped tableview. In this form I have UIswitches and textfields. But after scrolling down, the cells styles are changing.</p> <p>Here is my cellForRowAtIndex</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; static NSString *MyIdentifier = @"GenericCell"; cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] ; } NSString *text = nil; if(indexPath.section == CREDENTIALS_SECTION){ if (indexPath.row == 0) { NSLog(@"tot hier login"); UITextField *login = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)]; login.adjustsFontSizeToFitWidth = YES; login.placeholder = @"example@gmail.com"; login.keyboardType = UIKeyboardTypeEmailAddress; login.returnKeyType = UIReturnKeyNext; login.backgroundColor = [UIColor clearColor]; login.tag = 0; login.delegate = self; [login setEnabled: YES]; [cell addSubview:login]; }else if (indexPath.row == 1){ NSLog(@"tot hier pass"); UITextField *pass = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)]; pass.adjustsFontSizeToFitWidth = YES; pass.placeholder = @"Required"; pass.keyboardType = UIKeyboardTypeDefault; pass.returnKeyType = UIReturnKeyDone; pass.secureTextEntry = YES; pass.backgroundColor = [UIColor clearColor]; pass.tag = 0; pass.delegate = self; [cell addSubview:pass]; } if (indexPath.row == 0) { // Email text = @"Email"; } else if(indexPath.row == 1) { text = @"Password"; } }else if(indexPath.section == METHODS_SECTION){ UISwitch *toggleSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(220, 10, 100, 30)]; toggleSwitch.tag = indexPath.row; [toggleSwitch addTarget:self action:@selector(toggleSwitched:) forControlEvents:UIControlEventValueChanged]; [cell addSubview:toggleSwitch]; if (indexPath.row == 0) { // Web text = @"Web applicatie"; } else if(indexPath.row == 1) { //Mobile text = @"Mobiele applicatie"; } else if(indexPath.row == 2) { //Mail text = @"E-mail"; } }else if(indexPath.section == PHONE_SECTION){ UITextField *phoneText = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, 185, 30)]; phoneText.adjustsFontSizeToFitWidth = YES; phoneText.font = [UIFont fontWithName:@"Arial-BoldMT" size:18]; phoneText.keyboardType = UIKeyboardTypeNumberPad; phoneText.delegate = self; phoneText.textColor = [UIColor blackColor]; phoneText.text = _person.phone; [cell addSubview:phoneText]; }else if(indexPath.section == REMARK_SECTION){ UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(20, 10, 280, 260)]; textView.text = _person.remark; textView.delegate = self; textView.font = [UIFont fontWithName:@"Arial" size:15.0]; textView.backgroundColor = [UIColor clearColor]; [cell addSubview:textView]; text = @""; }else if(indexPath.section == BUTTON_SECTION){ cell.backgroundColor = [UIColor redColor]; text = @"test"; } cell.textLabel.text = text; return cell; } </code></pre> <p>After some searching I found that more people are having this problem. And that the problem lays in this piece of code.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; static NSString *MyIdentifier = @"GenericCell"; cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] ; } NSString *text = nil; </code></pre> <p>But I don't find a solution for it. Hope anybody can help!</p> <p>Kind regards! </p> <p><strong>Clarification</strong></p> <p>Oké so here you see a screenshot of my form. below I have a red cell (save button) when I scroll down other cells are getting a red background. And some cells, text property's are changing. <img src="https://i.stack.imgur.com/RWHPL.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload