textFieldDidEndEditing不能監聽到textFiled實時的改變,想要實現實時監聽 建議注冊通知去監聽textField的實時改變,直接上代碼:
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(infoAction)name:UITextFieldTextDidChangeNotificationobject:nil];
- (void)infoAction
{
NSIndexPath *index = [NSIndexPathindexPathForRow:0inSection:1];
OrderConfirmInfoTableViewCell *cell = (OrderConfirmInfoTableViewCell *)[_tableViewcellForRowAtIndexPath:index];
_phoneStr = cell.phoneField.text;
_addrStr = cell.addressField.text;
}
infoAction裡就可以把監聽的textfield的值的改變 實時的賦值給另一個對象。