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

前端 未结 3 847
春和景丽
春和景丽 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 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.

提交回复
热议问题