ios - UITextField 上的下拉菜单?

标签 ios objective-c uitextfield uipickerview actionsheetpicker

在我当前的 View 中,我有 7 个不同的文本字段。其中 1 个有 UIPicker作为它的input通过这样做:self.pickerTextField.inputView = _thePicker;
我的问题是:现在所有的文本字段看起来都一样,我尝试更改它们的配置,甚至添加一个小箭头指向带有选择器的那个,但它并没有给我我想要的外观。

这就是我现在所拥有的:

enter image description here

&这是我正在寻找的“菜单/下拉”外观:
enter image description here

就像我说的,我尝试添加箭头图像,但它没有像底部图片那样的 3D 外观。谢谢你的帮助!

编辑 : 我的问题不是关于 AccesoryView添加上一个/下一个/完成按钮。我的问题是关于更改实际 TextField 的外观。

最佳答案

我已经做了你想做的事情并使用了ActionSheetPicker .我对其进行了扩展并添加了 ActionSheetMultiPicker ,但听起来单个组件对您有用。

这非常有效,并产生了一个不错的 ActionSheet从底部呈现的样式选择器。

此外,我使用以下内容设置了当前属性,然后我在实例化 ActionSheetPicker 的方法中退出了第一响应者。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    curTextUIObject = textField;
    return YES;
}

然后我将editingDidBegin 连接到一个IBAction 以呈现ASPicker:
- (IBAction)relationshipPickerButtonPressed:(id)sender {
    [curTextUIObject resignFirstResponder];

     [ActionSheetStringPicker showPickerWithTitle:@"Select Relationship"
                                             rows:self.relationshipsArray
                                 initialSelection:self.selectedRelationshipIndex
                                           target:self
                                    successAction:@selector(relationshipWasSelected:element:)
                                     cancelAction:@selector(actionPickerCancelled:) origin:sender];
}

这是它在设备(模拟器)上的样子:
enter image description here

关于ios - UITextField 上的下拉菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17666060/

相关文章:

objective-c - 定义重复本地通知的结束日期

ios - uitextfield如何解析NSString

ios - TextField 第一个单元格结果显示在 Tableview 单元格的其他单元格中

ios - 在 TableView 中显示

ios - 更新了用户位置 : MKUserLocation for google maps ios swyft

ios - Xcode 调试检查器将值显示为 nil

ios - 在 iOS 中的 amazon s3 上设置文件权限

ios - xcode 5 - 打开一个没有 Storyboard的项目

ios - 从firebase数据库检索数据: code didn't go into the completion block or an error block

ios - 在 UITableViewController 上编辑 UITextField 时滚动区域不正确