我有一个 UITextField,它的右 View 有一个按钮。文本字段的输入 View 是一个 pickerView。现在,我在这里隐藏了文本字段的光标:
Hide the cursor of an UITextField
当我选择 textField 时,pickerView 出现。 pickerView 中的第一个值是 +1
。一切都很好,直到这里。
现在,当我从 pickerView 选择 +34
时,textField 中的文本向左移动,加号的一半在左侧不可见。在此之后,即使我选择+1
,加号的一半也隐藏在左边。我怀疑这与 textField 中的文本区域数量有关,因为文本大小增加了。虽然不确定。
请注意,当 pickerView 关闭时,TextField 中的文本会自行正确对齐。
我应该怎么做才能确保文本不会向左移动而整个内容仍然可见?
谢谢。
选择器代码
self.picker = UIPickerView()
self.picker.delegate = delegate
self.picker.dataSource = delegate
self.picker.showsSelectionIndicator = true
self.countriesSpinner = createPickerTextField([
"width": width,
"height": height,
"top": top,
"left": left
]) //This returns a text field
self.countriesSpinner.inputView = self.picker
最佳答案
试试这个,
在 iOS 模拟器中执行您的应用程序并转到 DEBUG-> Color Blended 层,看看会发生什么。您将能够在那里看到看不到完整文本的原因。
关于ios - 当 pickerView 出现时,UITextField 中的文本向左移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29027337/