简体   繁体   English

如何使 UIPickerView 在屏幕上滑动一半?

[英]How to make a UIPickerView slide half way up the screen?

在此处输入图像描述

when someone clicks clothing, I want the UIPickerView to slide up as in the example as follows:当有人点击衣服时,我希望 UIPickerView 向上滑动,如下例所示:在此处输入图像描述

Can someone show a code sample please?有人可以显示代码示例吗?

as dsc and Jason said, if you are using tableview, use its delegate method didSelectRowAtIndexPath, in it call an pickerview in an actionsheet.正如 dsc 和 Jason 所说,如果您使用的是 tableview,请使用其委托方法 didSelectRowAtIndexPath,在其中调用操作表中的选取器视图。

To know how to call an pickerview in an actionsheet, check this link: Add UIPickerView & a Button in Action sheet - How?要了解如何在操作表中调用选择器视图,请查看此链接: 在操作表中添加 UIPickerView 和按钮 - 如何?

Update :更新
This version is deprecated: use ActionSheetPicker instead.此版本已弃用:改用 ActionSheetPicker。

You can use animation if you want a "sliding" effect如果您想要“滑动”效果,可以使用 animation

[pickerView setFrame: CGRectMake([[self view] frame].origin.x, [[self view] frame].origin.y + 480.0, [[self view] frame].size.width, [[self view] frame].size.height)];
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDuration: 0.25];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[pickerView setFrame: yourDesiredEndFrame];
[UIView commitAnimations];

It's not tested but will give you an idea它没有经过测试,但会给你一个想法

I have been looking for a solution to this as well.我也一直在寻找解决方案。 What I found was this: https://github.com/TimCinel/ActionSheetPicker我发现的是: https://github.com/TimCinel/ActionSheetPicker

There is a sample project in the zip file that demonstrates how nicely it works. zip 文件中有一个示例项目,它演示了它的工作原理。

Enjoy!享受!


Update:更新:

This version is deprecated: use ActionSheetPicker-3.0 instead.此版本已弃用:改用ActionSheetPicker-3.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM