显示UIPickerView就像一个键盘,没有UITextField [英] Show UIPickerView like a keyboard, without UITextField

查看:79
本文介绍了显示UIPickerView就像一个键盘,没有UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击 UIBarButtonItem 时,我正在寻找一种方法来呈现 UIPickerView 。想象一下表格视图结果的过滤器。

I'm looking for a way to present a UIPickerView when the user taps on a UIBarButtonItem. Imagine a filter for the table view results.

我知道我可以使用 UITextField inputView,但这不会是这样 - 我只有一个 UIBarButtonItem 和一个 UITableView

I know I could use a UITextField inputView, but this would not be the case -- all I have is a UIBarButtonItem and a UITableView.

我见过使用 UIActionSheet ,但它看起来并不自然,特别是什么时候动画显示。

I've seen into using a UIActionSheet, but it does not look natural, specially when it's animating to show.

手动打开和关闭屏幕上的 UIView 是唯一的选择吗?

Would animating the UIView on and off the screen manually the only option?

该应用程序仅适用于iOS 6+和iPhone,因此我无需与任何其他版本/惯用语保持兼容。

The app is iOS 6+ and iPhone only, so I don't need to keep compatibility with any other versions/idioms.

推荐答案

它可能不是您唯一的选择,但动画UIPickerView对您来说应该相对容易。添加选择器视图,使其显示在屏幕底部。什么时候给它制作动画:

It might not be your only option but animating the UIPickerView should be relatively easy for you to do. Add the picker view so it's displayed off the bottom of the screen. When it's time to animate it in:

[UIView animateWithDuration:0.3 animations:^{
    self.datePicker.frame = CGRectMake(0, self.view.bounds.size.height - datePicker.bounds.size.height, datePicker.bounds.size.width, datePicker.bounds.size.height);
}];

什么时候隐藏它:

[UIView animateWithDuration:0.3 animations:^{
    self.datePicker.frame = CGRectMake(0, self.view.bounds.size.height, datePicker.bounds.size.width, datePicker.bounds.size.height);
}];

这篇关于显示UIPickerView就像一个键盘,没有UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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