【发布时间】:2013-04-22 03:38:12
【问题描述】:
您好,我正在使用以下代码,其中包含包含用户 ID 和密码字段的 alertView。
这些 UserID 和 Password 是文本字段,我将密码字段设置为安全的,但是当我以后想要访问密码字段中输入的数据时,它在密码字段中显示没有值..
我的代码是
self.loginPassword = [[ UIAlertView alloc] initWithTitle:@"Please Login" message:@"Enter Valid UserID and Password\n\n\n\n" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];
//[self.loginPassword setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
self.userIDText = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 80.0, 260.0, 25.0)];
self.userIDText.text=@"";
[self.userIDText setBackgroundColor:[UIColor whiteColor]];
[self.userIDText setKeyboardAppearance:UIKeyboardAppearanceAlert];
[self.userIDText setAutocorrectionType:UITextAutocorrectionTypeNo];
[self.userIDText setTextAlignment:UITextAlignmentLeft];
self.passwordField = [[UITextField alloc] initWithFrame:CGRectMake(12.0,115.0, 260.0, 25.0)];
self.passwordField.text=@"";
[self.passwordField setBackgroundColor:[UIColor whiteColor]];
[self.passwordField setKeyboardAppearance:UIKeyboardAppearanceAlert];
[self.passwordField setAutocorrectionType:UITextAutocorrectionTypeNo];
[self.passwordField setTextAlignment:UITextAlignmentLeft];
[self.loginPassword addSubview:self.userIDText];
[self.loginPassword addSubview:self.passwordField];
self.passwordField.secureTextEntry = YES;
[self.loginPassword setTag:2];
[self.loginPassword show];
[self.loginPassword release];
请给我一些解决方案..
【问题讨论】:
-
为什么要创建自己的文本字段而不是使用
UIAlertViewStyleLoginAndPasswordInput的样式? -
没有 iOS 4.3 将不支持这个.. 我正在创建 subView 到 alertView
标签: iphone ios objective-c ios5 ios4