https://github.com/marty-suzuki/pickerbutton
PickerButton is subclass of UIButton that presents UIPickerView in UIKeyboard.
https://github.com/marty-suzuki/pickerbutton
ios keyboard uibutton uipickerview
Last synced: about 1 year ago
JSON representation
PickerButton is subclass of UIButton that presents UIPickerView in UIKeyboard.
- Host: GitHub
- URL: https://github.com/marty-suzuki/pickerbutton
- Owner: marty-suzuki
- License: mit
- Created: 2019-02-17T18:19:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-08T11:37:37.000Z (over 5 years ago)
- Last Synced: 2025-04-10T01:48:46.335Z (about 1 year ago)
- Topics: ios, keyboard, uibutton, uipickerview
- Language: Swift
- Homepage:
- Size: 5.92 MB
- Stars: 45
- Watchers: 6
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PickerButton
[](https://developer.apple.com/iphone/index.action)
[](https://developer.apple.com/swift)
[](http://cocoapods.org/pods/PickerButton)
[](https://github.com/Carthage/Carthage)
[](http://cocoapods.org/pods/MisterFusion)
PickerButton is subclass of UIButton that presents UIPickerView in keyboard.

## Concept
When PickerButton is tapped, it presents UIPickerView on UIKeyboard.
| PickerButton | inputView | inputAccessoryView |
| :-: | :-: | :-: |
| PickerButton is in conformity to [UIKeyInput](https://developer.apple.com/documentation/uikit/uikeyinput). | PickerButton returns UIPickerView as [inputView](https://developer.apple.com/documentation/uikit/uiresponder/1621092-inputview). | PickerButton returns UIToolBar as [inputAccessoryView](https://developer.apple.com/documentation/uikit/uiresponder/1621119-inputaccessoryview). |
|  |  |  |
When selected row or component is changed, button title is automatically updated.
## Usage
PickerButton is almost same interface as UIPickerView.
```swift
class ViewController: UIViewController {
@IBOutlet weak var button: PickerButton!
let pickerValues: [String] = ["first", "second", "third"]
override func viewDidLoad() {
super.viewDidLoad()
button.delegate = self
button.dataSource = self
}
}
extension ViewController: UIPickerViewDelegate, UIPickerViewDataSource {
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerValues[row]
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerValues.count
}
}
```
To use PickerButton in Storyboard / Xib, set Custom Class to `PickerButton`.

## Requirements
- Swift 4.2
- Xcode 10.1 or greater
- iOS 10.0 or greater
## Installation
#### CocoaPods
PickerButton is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod "PickerButton"
```
#### Carthage
If you’re using [Carthage](https://github.com/Carthage/Carthage), simply add
PickerButton to your `Cartfile`:
```
github "marty-suzuki/PickerButton"
```
Make sure to add `PickerButton.framework` to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.
## Author
marty-suzuki, s1180183@gmail.com
## License
PickerButton is available under the MIT license. See the LICENSE file for more info.