我在PinCode设置屏幕中放置了4个连续的UITextField。现在我已经将这些UiTextFields设置为“密码保护”,但问题是当我在TextField中输入任何字符时,它首先显示该字符然后将其转换为*(或DOT)。就像它的默认行为一样。
现在有什么办法,当我开始输入该字段时,它不会向我显示该字符,只是继续在字段中打印DOT或*。
由于
答案 0 :(得分:1)
You can do one thing..
this is .h file------>
#import <UIKit/UIKit.h>
#define fontRegular @"Helvetica Neue"
#define fontBold @"HelveticaNeue-Bold"
@interface ABCViewController : UIViewController <UITextFieldDelegate>
{
NSString *strReturn;
}
@property(nonatomic,retain)NSString *strReturn;
@end
this is .m file--->
#import "ABCViewController.h"
@implementation ABCViewController
@synthesize strReturn;
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextField *txt_Fields= [[UITextField alloc]initWithFrame:CGRectMake(30, 0, 230, 44)];
txt_Fields.backgroundColor= [UIColor clearColor];
txt_Fields.delegate= self;
txt_Fields.clearButtonMode=YES;
txt_Fields.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[txt_Fields setFont:[UIFont fontWithName:fontRegular size:20.0]];
[txt_Fields setTextColor:[UIColor colorWithRed:105.0/255 green:105.0/255 blue:105.0/255 alpha:1.0]];
txt_Fields.borderStyle=UITextBorderStyleBezel;
txt_Fields.returnKeyType = UIReturnKeyDone;
txt_Fields.keyboardType=UIKeyboardTypeURL;
txt_Fields.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self.view addSubview:txt_Fields];
[txt_Fields release];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
self.strReturn=[NSString stringWithFormat:@"%@%@",strReturn,string];
textField.text=[NSString stringWithFormat:@"%@*",textField.text];
NSLog(@"str:- %@",self.strReturn);
return NO;
}
Note:-
But In this case you will have to maintain string manually, Means You will have to store the string in a string variable, you can not take textfield.text, because it will return - "****". And you will have to manage so many things manuaaly....
答案 1 :(得分:0)
这是不可能的。此功能在Apple中不可用。
答案 2 :(得分:0)
请记住,这是一款带有小键盘的移动设备。显示按下瞬间按下的键只是向用户保证他们按下正确的键。另外,因为它是一个移动设备,用户应该是唯一一个看着屏幕的用户。如果用户正在使用AirPlay共享屏幕,则应在输入密码信息之前将其关闭。
答案 3 :(得分:0)
您可能会看到以下示例:https://github.com/Koolistov/Passcode我希望能为您提供帮助。