- (BOOL)textFieldShouldEndEditing:(UITextField *)textField { NSString *value = [NSString stringWithFormat:@"%.2f", [textField.text floatValue]]; if ([value floatValue] >= 1) { textField.text = value; [self calculateServiceFees]; } else { self.values[@"xx"] = @"$0.00"; self.values[@"xxx"] = @"$0.00"; textField.text = ([value floatValue]>0.0)?value:@""; // [self.tableView performSelector:@selector(reloadData)]; [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; // [self.tableView reloadData]; } return YES; }
第一种解决方法:改成 performSelectorOnMainThread 调用刷新才成功。
第二种解决方法,就是放到 textFieldDidEndEditing 回调中处理
时间: 2024-10-11 12:24:53