skywinder / ActionSheetPicker-3.0

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.
http://skywinder.github.io/ActionSheetPicker-3.0
BSD 3-Clause "New" or "Revised" License
3.4k stars 740 forks source link

Selector for setDoneButton is not working #400

Closed quintonpryce closed 6 years ago

quintonpryce commented 6 years ago

Tried setting up an ActionSheetCustomPicker and I needed an action on done. The button title will change but the selector won't hook up.

picker?.setDoneButton(UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(Class.method(_:))))

I ended up using the actionSheetPickerDidSucceed() callback.

skywinder commented 6 years ago

You have to initialize it with the UIButton look at example: https://github.com/skywinder/ActionSheetPicker-3.0/blob/c78d7a8af26eb9e5f22ecb849c54804d6fd31be1/Example%20Projects/Example-for-iOS-7-and-6/Example/Classes/OldActionSheetPickerViewController.m#L186

your code should looks like this:

let button = UIButton(type: .custom)
//initalize your bar button there:
let buttonItem = UIBarButtonItem(customView: button)
picker?.setDoneButton(buttonItem)
skywinder commented 6 years ago

Feel free to reopen the issue, if you still need help. 👍