当secureTextEntry设置为NO时,UITextField内存泄漏

时间:2011-01-19 12:09:39

标签: iphone cocoa-touch memory-leaks uitextfield

我有两个UITextField,一个将secureTextEntry设置为YES,另一个设置为NO。我的UITextField中有内存泄漏,其中secureTextEntry设置为NO,如果我将其设置为YES,则没有内存泄漏。我不知道为什么secureTextEntry会改变行为。

login = [[UITextField alloc] initWithFrame:CGRectMake(51.0, 160.0, 218.0, 21.0)];
login.textAlignment = UITextAlignmentLeft;
login.textColor = [UIColor whiteColor];
login.backgroundColor = [UIColor blackColor];
login.secureTextEntry = NO;
login.placeholder = @"Identifiant";
login.returnKeyType = UIReturnKeyDone;
login.clearsOnBeginEditing = YES;
login.autocapitalizationType = UITextAutocapitalizationTypeNone;
login.delegate = self;
login.font = [UIFont fontWithName:@"Helvetica Neue" size:15.0];
[login addTarget:self action:@selector(goAwayKeyboard:) forControlEvents:UIControlEventEditingDidEndOnExit ];
[self.view addSubview:login];

password = [[UITextField alloc]initWithFrame:CGRectMake(51.0, 200.0, 218.0, 21.0)];
password.textAlignment = UITextAlignmentLeft;
password.textColor = [UIColor whiteColor];
password.backgroundColor = [UIColor blackColor];
password.secureTextEntry = YES;
password.placeholder = @"Mot de passe";
password.returnKeyType = UIReturnKeyDone;
password.clearsOnBeginEditing = YES;
password.delegate = self;
password.font = [UIFont fontWithName:@"Helvetica Neue" size:15.0];
[password addTarget:self action:@selector(goAwayKeyboard:) forControlEvents:UIControlEventEditingDidEndOnExit ];
[self.view addSubview:password];

这是goAwayKeyboard,但我试过没有打电话给这个,没有任何改变。

if(sender)[sender resignFirstResponder];

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
animation.removedOnCompletion = YES;  
animation.fromValue = [NSNumber numberWithFloat:self.view.layer.frame.origin.y];
animation.toValue = [NSNumber numberWithFloat:0.0];
animation.duration = 0.5;
animation.fillMode = kCAFillModeRemoved;
animation.additive = YES;

[self.view.layer addAnimation:animation forKey:nil];
[self.view setFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];

0 个答案:

没有答案