每一个,
我在带有安全textField的ios 6中遇到了问题。当我单击键盘上的“完成”按钮时,它会自动删除内容。我检查了安全textField的值。
在textFieldShouldReturn
中,secureTextField.text
是正确的。但在textFieldDidEndEditing
中,secureTextField.text
变为零。
相同的secureTextField在ios 5.1上运行良好。如果我将secureTextField作为普通的textField(不安全),那么一切顺利。也就是说,notSecuredTextField.text在textFieldShouldReturn
或textFieldDidEndEditing
中都是正确的。
有什么想法吗?
以下是代码:
(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.textFieldPassword){ if ([self.textFieldUserName.text length] != 0){ [self loginMe]; NSLog(@"should return %@", self.textFieldPassword.text);//The value is correct [self.textFieldPassword resignFirstResponder]; } } return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
NSLog(@"Did End Editing %@", self.textFieldPassword.text);
if(textField == _textFieldPassword){
NSLog(@"in text field did end editing %@", self.textFieldPassword.text); // The value is null
}
}
答案 0 :(得分:1)
似乎调用resignFirstResponder
会导致不受欢迎的操作。因此,在调用该方法之前复制数据可以解决此问题。当然,这并没有真正解决问题,它只是隐藏问题的解决方案。
我为iOS 6创建了一个新项目,问题没有出现。