Showing a UIPickerView with UIActionSheet in iOS8 not working

Gabriel.Massana picture Gabriel.Massana · Jun 20, 2014 · Viewed 42.2k times · Source

Showing a UIPickerView with UIActionSheet in iOS8 not working

The code works in iOS7, however it is not working in iOS8. I'm sure it is because UIActionSheet is deprecated in iOS8 and Apple recommends to use UIAlertController.

However, how to do it in iOS8? I should use UIAlertController?

iOS7:
enter image description here

iOS8:
enter image description here

EDIT:

My GitHub project solving the problem.

Answer

David Berry picture David Berry · Jun 20, 2014

From the reference for UIActionSheet:

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

My guess is your seeing exactly why.

The reference for UIAlertController doesn't have a similar disclaimer, but looking at its interface, my guess is Apple will add it before release.

My recommendation would be to just create a small view containing your picker and buttons and show and hide it as needed. It's not that hard to do and your not pushing interfaces beyond their intended uses.