简体   繁体   中英

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:在此处输入图像描述

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.

To know how to call an pickerview in an actionsheet, check this link: Add UIPickerView & a Button in Action sheet - How?

Update :
This version is deprecated: use ActionSheetPicker instead.

You can use animation if you want a "sliding" effect

[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

There is a sample project in the zip file that demonstrates how nicely it works.

Enjoy!


Update:

This version is deprecated: use ActionSheetPicker-3.0 instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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