本文介绍了通过在运行时更改UITextFieldBorderStyle,iOS 5中的UITextField问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在突然遇到一些UITextFields,因为我正在iOS 5设备上进行测试,即使我在iOS 5 SDK中构建了应用程序并且已经让错误发布了。

I'm suddenly having trouble with some UITextFields now that I'm testing on iOS 5 devices, even though I built the app in iOS 5 SDK and already let the bug slip through to release.

我有一个允许输入的文本字段,当你按下锁定按钮时,它会调用:

I have a textfield that allows input, and when you press a "lock" button, it calls:

textField.enabled = NO;
textField.borderStyle = UITextBorderStyleNone;

字段隐藏但仍然像标签一样 - 应用程序的重要功能。

The Field "hides" but still acts like a label - important function for the app.

然后再次按下锁定按钮并调用:

Then you press the "lock" button again and it calls:

textField.enabled = YES;
textField.borderStyle = UITextBorderStyleRoundedRect;

这在4.2 / 4.3中完美无缺,但在iOS 5中,唯一出现的是斜面轮廓没有白色背景颜色的文本字段。

This works perfectly in 4.2/4.3 but in iOS 5 the only thing that appears is the beveled outline of the textfield with no white background color.

设置.backgroundColor在iOS 5上修复它,但在4.2 / 4.3上形成一个丑陋的白色方块。

Setting .backgroundColor fixes it on iOS 5 but makes an ugly white square on 4.2/4.3.

我没有看到API差异文档中有关这些更改的内容,我在这里缺少什么?
在此先感谢..

I didn't see anything about these changes in the API diffs document, what am I missing here??Thanks in advance..

推荐答案

如果您对白色背景感觉不错,我会将此评论修复为行指定背景颜色并将opaque属性设置为NO

If you are fine with the white background, I fixed this commenting out the line that specifies a background color and setting the opaque property to NO

//[myTextField setBackgroundColor:[UIColor whiteColor]];

[myTextField setOpaque:NO];

这解决了iOS 4.3和iOS 5.0的问题

This has resolved the issue for both iOS 4.3, and iOS 5.0

-Alex

这篇关于通过在运行时更改UITextFieldBorderStyle,iOS 5中的UITextField问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:21