2016-11-15 65 views
0

我有UIAlertView與文本字段。uialertview textfield隱形ios 10.1.1

UIAlertView *corrmsg=[[UIAlertView alloc] initWithTitle:@"" message:@"Enter Password" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",@"Forgot Password", nil]; 
    corrmsg.alertViewStyle = UIAlertViewStylePlainTextInput; 
    [corrmsg show]; 
    [corrmsg release]; 

在iPad上的iOS 9.1.1文本字段成爲無形的,沒有光標,沒有包裝,雖然鍵盤上來和工作正常,如果你只是一味地鍵入英寸

enter image description here

任何人有線索怎麼解決這個問題?

切換到UIAlertController但這並沒有幫助:(

 UIAlertController *alertController=[UIAlertController alertControllerWithTitle:@"" message:@"Enter Password" preferredStyle:UIAlertControllerStyleAlert]; 

    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){ 
     textField.placeholder = NSLocalizedString(@"Enter Password", @"Password"); 
    }]; 

    [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
     [self okBttn:alertController.textFields.firstObject.text]; 
    }]]; 
    [alertController addAction:[UIAlertAction actionWithTitle:@"Forgot Password" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
     [self forgotPasswordBttn]; 
    }]]; 
    [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
     [self cancelBttn]; 
    }]]; 
    [self presentViewController:alertController animated:YES completion:nil]; 
    [alertController release]; 

UPDATE:?提升部署目標> 9.0固定UIAlertController

+1

'UIAlertView'已被棄用一段時間了。使用'UIAlertController'。 – rmaddy

+0

嗨rmaddy,切換到UIAlertController - 同樣的故事,任何其他想法? –

+0

將depl traget升級到> 9.0固定UIAlertController –

回答

0

凡茹配置UITextField 嘗試smthn這樣的:

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:(@"") 
                message:@"Enter Password" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; 
[myTextField setBackgroundColor:[UIColor whiteColor]]; 
[myAlertView addSubview:myTextField]; 
[myAlertView show]; 
[myAlertView release]; 
} 
+0

因爲我使用myAlertView.alertViewStyle = UIAlertViewStylePlainTextInput;我不需要,但是謝謝你的建議。我可以嘗試[myAlertView textFieldAtIndex:0] .backgroundColor = [UIColor whiteColor];等等,但是,正如rmaddy指出的那樣,它已被棄用,我將切換到UIAlertController以避免未來的不可預測性。 –

+0

1)'UIAlertView'已棄用。 2)不要創建自己的'UITextField'並將其添加到警報中。 'UIAlertView'已經支持添加文本字段。 3)你真的還在使用MRC而不是ARC嗎? – rmaddy

+0

好的,rmaddy,我不會在已經存在的那個頂部添加textview,我可以訪問它並進行編輯。這是一箇舊的應用程序,是的,它是MRC。需要將其切換到ARC並提升其部署目標。 –