UIAlertViewStyleLoginAndPasswordInput占位符文本将不会设置

时间:2014-02-03 14:37:27

标签: ios iphone objective-c ipad uialertview

我有一个使用UIAlertViewStyleLoginAndPasswordInput警报视图的应用。一切正常,但密码字段的占位符文本有一些奇怪的行为。在我的SIM卡上,无论我将其设置为什么,它都拒绝改变“密码”。而且我一直有报道它在“密码”和我希望设置它的值之间翻转。这似乎与iOS7有关。

我正在尝试在'willPresentAlertView'委托中设置这些值。

- (void)willPresentAlertView:(UIAlertView *)alertView
{
    ...


   else if (alertView.tag == UIAlertViewTagInactivityTimeOut)
   {
    badgeNumberTextField = [alertView textFieldAtIndex:0];
    verifyBadgeNumberTextField = [alertView textFieldAtIndex:1];

    [badgeNumberTextField setPlaceholder:@"Badge Number"];
    [verifyBadgeNumberTextField setPlaceholder:@"Verify Badge Number"];

    [verifyBadgeNumberTextField setSecureTextEntry:NO];

    [badgeNumberTextField setFont:[UIFont systemFontOfSize:ALERT_VIEW_TEXTFIELD_TEXT_FONT]];
    [verifyBadgeNumberTextField setFont:[UIFont systemFontOfSize:ALERT_VIEW_TEXTFIELD_TEXT_FONT]];

    [badgeNumberTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
    [verifyBadgeNumberTextField setKeyboardType:UIKeyboardTypeNamePhonePad];

    [badgeNumberTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
    [verifyBadgeNumberTextField setClearButtonMode:UITextFieldViewModeWhileEditing];

    [badgeNumberTextField setDelegate:self];
    [verifyBadgeNumberTextField setDelegate:self];

    ...
     //other code 
  }
}

1 个答案:

答案 0 :(得分:13)

您是否尝试过设置创建UIAlertView的占位符?

试试这个:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Login", nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
[alert textFieldAtIndex:0].placeholder = @"Username placeholder";
[alert textFieldAtIndex:1].placeholder = @"Password placeholder";
[alert show];