如果我设置了clearsOnBeginEditing并且有一个安全的文本字段,并且如果您失去对该字段的焦点并再次返回并开始输入,它将始终清除该文本字段。有没有人有办法解决这个问题?带有secureTextEntry的UITextField不尊重clearsOnBeginEditing
1
A
回答
-1
我刚刚遇到同样的问题。我正在从textFieldDidBeginEditing:call中更改属性。
将属性更改移至textFieldShouldBeginEditing:call修复了问题。
0
保存在属性中输入的文本。例如:
NSString *_password;
然后在委托:
textFieldDidBeginEditing:(UITextField *)textField
分配textField.text = _password;
0
我子类的UITextField此。我有掩蔽的UITextField(用于打开安全入口和关闭)在屏幕上单独控制,这是一个更合适的地方为我解决这个问题:
@interface ZTTextField : UITextField {
BOOL _keyboardJustChanged;
}
@property (nonatomic) BOOL keyboardJustChanged;
@end
@implementation ZTTextField
@synthesize keyboardJustChanged = _keyboardJustChanged;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_keyboardJustChanged = NO;
}
return self;
}
- (void)insertText:(NSString *)text {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
if (self.keyboardJustChanged == YES) {
BOOL isIOS7 = NO;
if ([[UIApplication sharedApplication] respondsToSelector:@selector(backgroundRefreshStatus)]) {
isIOS7 = YES;
}
NSString *currentText = [self text];
// only mess with editing in iOS 7 when the field is masked, wherein our problem lies
if (isIOS7 == YES && self.secureTextEntry == YES && currentText != nil && [currentText length] > 0) {
NSString *newText = [currentText stringByAppendingString: text];
[super insertText: newText];
} else {
[super insertText:text];
}
// now that we've handled it, set back to NO
self.keyboardJustChanged = NO;
} else {
[super insertText:text];
}
#else
[super insertText:text];
#endif
}
- (void)setKeyboardType:(UIKeyboardType)keyboardType {
[super setKeyboardType:keyboardType];
[self setKeyboardJustChanged:YES];
}
@end
0
这个工作对我来说:为了返回FALSE禁止textview自行更改和设置更改。
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *newContent = [textField.text stringByReplacingCharactersInRange:range withString:string];
[textField setText:newContent];
return FALSE;
}
相关问题
- 1. UITextField secureEntry不尊重clearsOnBeginEditing属性
- 2. UITextView不尊重secureTextEntry属性
- 3. 带有QuickDialog和JSON的SecureTextEntry?
- 4. iOS 11.0 UITextField secureTextEntry不起作用?
- 5. UITextField在secureTextEntry切换后有空格后面的空格
- 6. 简单的问题关于UITextField和不工作secureTextEntry
- 7. 带通滤波器不尊重截止
- 8. 带有FontAwesome的UITextField
- 9. 带有归属文本不尊重的UIButton adjustsFontSizeToFitWidth
- 10. IE不尊重:
- 11. MonoTouch:带有UITextField的UIAlertView?
- 12. UITextField跟在secureTextEntry后面的空格开关
- 13. 的UITextField secureTextEntry - 作品是从去NO,但变回是没有效果的上述
- 14. 不尊重条件
- 15. mod_wsgi不尊重WSGIPythonHome
- 16. Android:ViewPager不尊重WRAP_CONTENT?
- 17. MapFragment不尊重matchparent
- 18. url_for不尊重default_url_options
- 19. 宽度不尊重
- 20. GetChildAtPoint不尊重ZOrder
- 21. 约束不尊重
- 22. Eclipse不尊重.cvsignore
- 23. IE不尊重NBSP
- 24. ReactiveCommand不尊重canExecute
- 25. SerialPort.Read(....)不尊重ReadTimeOut
- 26. URLConnection不尊重ReadTimeout
- 27. SpriteKit不尊重zPosition?
- 28. 的WebPack不尊重的package.json
- 29. DockedItems不尊重重量
- 30. 的NSTextField securetextentry
我有一个像你说的尝试,但它没有工作... – cloosen 2012-09-18 08:51:50