我有可编辑的表格视图单元格,当我从表格中的第一个文本字段移动到最后一个文本字段时,它崩溃了。代码是。下面的代码用于文本字段委托
-(void)textFieldDidBeginEditing:(UITextField *)sender
{
NSIndexPath *indexpath = [NSIndexPath indexPathForRow:sender.tag inSection:1];
EditableTextFieldCell *cell = (EditableTextFieldCell *)[self.documentdetailTable cellForRowAtIndexPath:indexpath];
self.actField = cell.textFieldOne;
if([self.actField canBecomeFirstResponder]){
[self.actField becomeFirstResponder];
}
}
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
if (self.actField == textField) {
[self.actField resignFirstResponder];
}
return YES;
}
-(void)textFieldDidEndEditing:(UITextField*)sender
{
if (self.quantityValue !=nil)
{
[self.quantityArray replaceObjectAtIndex:[sender tag] withObject:sender.text];
[[self.documentItemsArray objectAtIndex:[sender tag]] setQUANTITY:[NSNumber numberWithDouble:[sender.text doubleValue]]];
[self.documentdetailTable reloadData];
}
}
- (BOOL)textFieldShouldClear:(UITextField *)textField {
self.quantityValue=@"";
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
-(void)textFieldDidChange:(UITextField *)theTextField
{
NSLog( @"text changed: %@", theTextField.text);
self.quantityTextField = theTextField;
self.actField = theTextField;
}
//add the textfield listeners
[self.quantityTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingDidBegin];
但它正在崩溃,我收到如下消息:
**EditableTextFieldCell _didChangeToFirstResponder:]: message sent to deallocated instance 0xc3c6bf0**