如何在UIPickerView顶部添加UIToolbar? (iPhone/iPad) [英] How to add a UIToolbar on top of UIPickerView? (iPhone/iPad)
问题描述
在我的应用程序中,我有一个按钮,当按下该按钮时,应在其顶部显示一个UIPickerView
和一个UIToolbar
.当用户在UIPickerView
中选择了值后,他们将按UIToolbar
中的按钮,同时取消UIPickerView
和UIToolbar
.
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
的全局对象,然后将UIToolbar
和UIPickerview
添加到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屋!