HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 想在UIAlertController或UIPopoverController Swift中显示UIPickerView吗?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在UIAlertController或UIPopoverController中显示UIPickerView,我是iOS新手,请在这里给我一些示例代码.

搜索了他们但找不到任何满意的答案.我不想在UIActionSheet上这样做,因为它在iOS 9中已被弃用.我也希望它在Swift中而不是在Obj-C中.我尝试了下面的例子,但它不适合我.

http://makeapppie.com/2014/08/30/the-swift-swift-tutorials-adding-modal-views-and-popovers/

解决方法

你的基本代码看起来像:
let alert = UIAlertController(title: title,message: message,preferredStyle: .actionSheet)
alert.isModalInPopover = true

//  Create a frame (placeholder/wrapper) for the picker and then create the picker
let pickerFrame = CGRect(x: 17,y: 52,width: 270,height: 100) // CGRectMake(left),top,width,height) - left and top are like margins
let picker = UIPickerView(frame: pickerFramE)

//  set the pickers datasource and delegate
picker.delegate = self
picker.datasource = self

//  Add the picker to the alert controller
alert.view.addSubview(picker)

//Do stuff and action on appropriate object.

请查看以下答案.

Is there any way to add UIPickerView into UIAlertController (Alert or ActionSheet) in Swift?

大佬总结

以上是大佬教程为你收集整理的ios – 想在UIAlertController或UIPopoverController Swift中显示UIPickerView吗?全部内容,希望文章能够帮你解决ios – 想在UIAlertController或UIPopoverController Swift中显示UIPickerView吗?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。