UITextField上的下拉菜单?

时间:2013-07-16 00:22:21

标签: ios objective-c uitextfield uipickerview actionsheetpicker

在我目前的观点中,我有7个不同的文字字段。其中1个作为UIPicker input执行:self.pickerTextField.inputView = _thePicker;

我的问题是:现在所有文本字段看起来都一样,我尝试更改他们的配置,甚至添加一个小箭头指向带有Picker的那个但是它不会给我看起来我看起来对

这就是我现在所拥有的:

enter image description here

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

就像我说的那样,我尝试过添加箭头图像,但它不像底部图片那样具有3D效果。谢谢你的帮助!

修改:我的问题与AccesoryView添加prev / next / done按钮无关。我的问题是关于改变TextField的实际外观。

1 个答案:

答案 0 :(得分:4)

我已经完成了您要做的事情并使用了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