在iOS8中显示带有UIActionSheet的UIPickerView无法正常工作 [英] Showing a UIPickerView with UIActionSheet in iOS8 not working
问题描述
在 iOS8 无效
该代码适用于 iOS7 ,但不适用于 iOS8 。我确定这是因为UIActionSheet在 iOS8 中已被弃用,Apple建议使用 UIAlertController
。
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
.
但是,如何在 iOS8 中执行此操作?我应该使用 UIAlertController
?
However, how to do it in iOS8? I should use UIAlertController
?
iOS7 :
< img src =https://i.stack.imgur.com/kKWxa.pngalt =在此输入图像说明>
iOS7:
iOS8 :
iOS8:
编辑:
推荐答案
来自UIActionSheet的参考资料:
From the reference for UIActionSheet:
UIActionSheet不是为子类设计的,也不应该为其层次结构添加视图。如果您需要提供比UIActionSheet API提供的更多自定义的工作表,您可以创建自己的工作表并使用presentViewController以模态方式呈现它:animated:completion:。
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.
UIAlertController的参考没有类似的免责声明,但看看它的界面,我的猜测Apple会在发布之前添加它。
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.
这篇关于在iOS8中显示带有UIActionSheet的UIPickerView无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!