Search code examples
iosobjective-cxcode7uialertcontroller

UIAlertController textfield width is way smaller than usual


So I have a UIAlertController with a UITextField added for an input but for some reason the textfield appears to be much smaller than it's supposed to be. Any idea why?

Here is the Screenshot

Alert view textfield image

Here is the Code

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"This is title"
                                                               message:@"This is message"
                                                        preferredStyle:UIAlertControllerStyleAlert];

[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {

    textField.keyboardType = UIKeyboardTypeNumberPad;
    textField.placeholder = @"I am a placeholder";

}];


UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Submit"
                                              style:UIAlertActionStyleDefault
                                            handler:nil];

[alert addAction:okAction];


[self presentViewController:alert animated:YES completion:nil];

Thanks!


Solution

  • This was a very interesting bug. The project we were working on had a library called Pixate Freestyle, which uses CSS to style app's elements. It was breaking the textfields by styling it. We removed it from the project and styled it natively. The problem was solved. Hope this helps!