iOS 7: on textfield did change the firstresponder my application is crashing

前端 未结 3 827
春和景丽
春和景丽 2021-01-14 20:13

I have editable tableview cell,and when i move from first textfield to last textfield in the table it is crashing.Code is.The below code is for textfield delegate

         


        
相关标签:
3条回答
  • 2021-01-14 20:56

    Had the same issue. I fixed it by placing identifier to the table view cell's nib file. then a dequeue call at cellForRowAtIndexPath:

    static NSString *fsCellIdentifier = @"configurationCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:fsCellIdentifier];
    
    0 讨论(0)
  • 2021-01-14 21:06

    May be this answer somewhat is stupid but the correct answer. I have checked for tableview cellforrowatindexpath and added an identifier

    static NSString *EditableTextFieldCellIdentifier = @"EditableCell";
    
    // using custom cells to show textfield and multiple columns
    EditableTextFieldCell *cellText = [tableView dequeueReusableCellWithIdentifier:EditableTextFieldCellIdentifier];
    

    And this fixed my problem and also crash.

    0 讨论(0)
  • 2021-01-14 21:11

    We had the same issue and it was because we where using "old code" to create/dequeue the custom UITableViewCells...

    What we had to do was to add this lines in the ViewDidLoad

    [self.myTableView registerClass:[ExpenseListCell class] forCellReuseIdentifier:@"ExpenseListCell"];
    [self.myTableView registerNib:[UINib nibWithNibName:@"ExpenseListCell" bundle:nil] forCellReuseIdentifier:@"ExpenseListCell"];
    

    and then "clean" the function cellForRowAtIndexPath to just use the dequeue function:

    ExpenseListCell *cell = (ExpenseListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    

    I suspect that, since they included storyboards, the dequeueReusableCellWithIdentifier manages the creation of the cells, so you don't need anymore this lines that we where still using after the dequeue:

    if(cell == nil)
    {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ExpenseListCell" owner:cell options:nil] objectAtIndex:0];
    }
    

    NOTA: We are not using storyboards

    Changing this, solved our problem on iOS7.

    0 讨论(0)
提交回复
热议问题