0

我在 PinCode 设置屏幕中放置了 4 个连续的 UITextField。现在我已将这些 UiTextFields 设为“受密码保护”,但问题是当我在 TextField 中输入任何字符时,它首先显示该字符,然后将其转换为 *(或 DOT)。就像它的默认行为一样。

现在有什么方法可以让我开始在该字段中输入它不会显示该字符,而是继续在该字段中打印 DOT 或 *。

谢谢

4

4 回答 4

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.... 
于 2012-09-04T12:54:07.773 回答
0

请记住,这是一个带有小键盘的移动设备。显示被按下的键只是让用户确信他们按下了正确的键。也因为它是一个移动设备,用户应该是唯一一个看屏幕的人。如果用户正在使用 AirPlay 共享屏幕,他们应该在输入密码信息之前将其关闭。

于 2012-09-04T11:59:08.113 回答
0

您可能会看到以下示例:https ://github.com/Koolistov/Passcode希望对您有所帮助。

于 2012-09-04T15:10:51.037 回答
0

这不可能。苹果没有这个功能。

于 2012-09-04T11:34:00.623 回答