Swift的组合框组件(失败于DownPicker) [英] Combobox component for Swift (failed with DownPicker)

查看:82
本文介绍了Swift的组合框组件(失败于DownPicker)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当下拉列表时,我需要像comboBox这样的组件,并允许用户选择值. PickerView看起来很糟糕,我发现外观很好看的是 DownPicker

I need a component like comboBox when it dropes down and allow user to select value. PickerView looks terrible and one I found nice looking was DownPicker

我按照说明进行了安装,安装并尝试使用,但没有看到传递给该组件的数据.

I followed instructions, installed it and tried to use but I did not see the data I pass to this component in it.

let data = NSMutableArray()
        data.addObject("1")
        data.addObject("2")
        data.addObject("3")

        let a = DownPicker(textField: group!, withData: data)

当我点击向下箭头图标时也没有任何反应

Also nothing happens when I tap down arrow icon

请给我一个建议,例如另一个组件,它可以与xcode 7 beta 6一起正常工作,或者帮助我解决当前尝试中的问题.谢谢)

Just advice me another components like this one which will work correctly with xcode 7 beta 6 or help me to fix problems with current try. Thanks)

更新: 我刚刚尝试了一个.也没什么好:\

Update: I've just tried this one. Nothing good from it too :\

推荐答案

DownPicker与Swift配合正常.我只是尝试过并在我的项目中使用它.我看到的问题是您将DownPicker初始化为局部变量.有两种方法可以在项目中使用DownPicker,并且看起来您选择了Control Wrapper.因此,您应该在控制器中包含以下控件:

DownPicker is working fine with Swift. I just tried it and use it in my project. The problem I see is that you init DownPicker to local variable. There are two ways how you can use DownPicker in your project and it looks you choose Control Wrapper. So you should have in your controller these controls:

@IBOutlet weak var personTextField: UITextField!
var personDownPicker: DownPicker!

第一个是连接到故事板中添加的UITextField的插座.我在viewDidLoad中初始化的DownPicker:

The first one is outlet connected to UITextField added in storyboard. DownPicker I Initialized in viewDidLoad:

override func viewDidLoad() {
        super.viewDidLoad()

        let persons: NSMutableArray = ["Architect", "Designer"]
        self.personDownPicker = DownPicker(textField: self.personTextField, withData:persons)
}  

这篇关于Swift的组合框组件(失败于DownPicker)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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