UIAlertController的文本字段宽度比平常小 [英] UIAlertController textfield width is way smaller than usual

查看:127
本文介绍了UIAlertController的文本字段宽度比平常小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个 UIAlertController ,为输入添加了 UITextField 但由于某种原因,文本字段似乎是比它应该的要小得多。知道为什么吗?

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?

这是截图

以下是代码

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];

谢谢!

推荐答案

这是一个非常有趣的错误。我们正在开发的项目有一个名为Pixate Freestyle的库,它使用CSS来设置app的元素。它通过造型来打破文本区域。我们将它从项目中删除并原生样式。问题解决了。希望这有帮助!

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!

这篇关于UIAlertController的文本字段宽度比平常小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆