2013-08-25 69 views

回答

2

是的,使用的方法 - 的TextField:shouldChangeCharactersInRange:replacementString:在UITextFieldDelegate。

f.e.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 
NSString* encodedString = [self encode:string]; 
textField.text = [textField.text stringByReplacingCharactersInRange:range withString: 
     encodedString]; 
self.decodedTextField.text = [self.decodedTextField.text stringByReplacingCharactersInRange:range withString:string]; 
return NO;     
} 

這僅僅是一個例子,您應該更加小心地實施更換。

+0

好的,這是要改變爲代碼和我如何做反向解碼「d」到「a」? – frank0ch0a

+0

textField2.text = [self decode:textFiled1.text],是你想要的嗎? – BergP

+0

是的,我想在第二個texfield返回以前輸入的「d」到「a」的字母 – frank0ch0a