如何在UIPickerView顶部添加UIToolbar? (iPhone/iPad) [英] How to add a UIToolbar on top of UIPickerView? (iPhone/iPad)

查看:90
本文介绍了如何在UIPickerView顶部添加UIToolbar? (iPhone/iPad)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个按钮,当按下该按钮时,应在其顶部显示一个UIPickerView和一个UIToolbar.当用户在UIPickerView中选择了值后,他们将按UIToolbar中的按钮,同时取消UIPickerViewUIToolbar.

In my app I have a button that when pressed should present a UIPickerView with a UIToolbar on top of it. When the user has selected the value in the UIPickerView they then press a button in the UIToolbar which dismisses both the UIPickerView and UIToolbar.

我遇到的问题是我不知道将UIToolbar添加到UIPickerView的方法.通常我会进行UITextField中的值受UIPickerView中的选择影响的设置.这样,我可以简单地将UIToolbar设置为inputAccessoryView,但是,这次我没有UITextField.

The problem I'm having is that I can't figure out a way to add the UIToolbar to the UIPickerView. Normally I would have a setup where a value in a UITextField is impacted by the selection in the UIPickerView. This way I can simply set the UIToolbar as the inputAccessoryView, however, this time round I don't have a UITextField.

请问有人可以建议如何在UIPickerView顶部添加UIToolbar吗?

Please can someone advise on how to add the UIToolbar on top of the UIPickerView?

推荐答案

为此的最佳解决方案是使用UIActionSheet.

Best Solution for this is make use of UIActionSheet.

只需创建UIActionSheet的全局对象,然后将UIToolbarUIPickerview添加到UIActionSheet作为子视图.

Just Create Global of UIActionSheet,add Your UIToolbar and UIPickerview to UIActionSheet as subview.

最后在主视图的子视图中添加UIActionSheet.

At last add UIActionSheet in subview of your main View.

希望它会为您提供帮助!!

Hope It will help you.!!

这篇关于如何在UIPickerView顶部添加UIToolbar? (iPhone/iPad)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆