Search code examples
iosios9uialertviewuialertcontroller

ios9 UIAlertController uitextfield too small


I am using this code to show UIAlert which will ask simple input

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Alert" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Click" style:UIAlertActionStyleDefault handler:nil]];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"Enter text:";
}];
[self presentViewController:alert animated:YES completion:nil];

Also tried this code of iOS 7

UIAlertView *alertViewCustomQuestion=[[UIAlertView alloc]initWithTitle:@"Custom Question" message:@"Please enter your custom question!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
alertViewCustomQuestion.alertViewStyle=UIAlertViewStylePlainTextInput;
[alertViewCustomQuestion show];

Both shows same result. While any example I saw has good width.enter image description here


Solution

  • I was fixing bugs of someone's else code, Finally found there was some category that was changing its behavior.