Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 474
theCoderGuy Avatar asked Sep 22 '15 16:09

theCoderGuy


1 Answers

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!

like image 63
theCoderGuy Avatar answered Oct 13 '22 07:10

theCoderGuy