0
我在我的iPad應用程序的UITableViewCell裏面有一個UITextField。如果我輸入文本,然後按解除鍵盤按鈕,它將保存文本,但如果我點擊更改視圖而不關閉鍵盤,它不會保存文本。UITextField委託不工作
我使用此代碼嘗試resigning textField作爲第一響應者,但沒有運氣。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (int it=0; it < [self.clinicalChecklist count]; ++it)
{
ClinicalChecklistCell *cell = (ClinicalChecklistCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:it inSection:0]];
UITouch *touch = [[event allTouches] anyObject];
if ([cell.col1_singleEntryValue isFirstResponder] && [touch view] != cell.col1_singleEntryValue) {
[cell.col1_singleEntryValue resignFirstResponder];
}
if ([cell.col2_singleEntryValue isFirstResponder] && [touch view] != cell.col2_singleEntryValue) {
[cell.col2_singleEntryValue resignFirstResponder];
}
if ([cell.col1_doubleEntryValue_1 isFirstResponder] && [touch view] != cell.col1_doubleEntryValue_1) {
[cell.col1_doubleEntryValue_1 resignFirstResponder];
}
if ([cell.col1_doubleEntryValue_2 isFirstResponder] && [touch view] != cell.col1_doubleEntryValue_2) {
[cell.col1_doubleEntryValue_2 resignFirstResponder];
}
if ([cell.col2_doubleEntryValue_1 isFirstResponder] && [touch view] != cell.col2_doubleEntryValue_1) {
[cell.col2_doubleEntryValue_1 resignFirstResponder];
}
if ([cell.col2_doubleEntryValue_2 isFirstResponder] && [touch view] != cell.col2_doubleEntryValue_2) {
[cell.col2_doubleEntryValue_2 resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
}