6

enter image description here

when someone clicks clothing, I want the UIPickerView to slide up as in the example as follows: enter image description here

Can someone show a code sample please?

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169

3 Answers3

9

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?

Community
  • 1
  • 1
SriPriya
  • 1,240
  • 15
  • 22
  • Looks like apple is about to start enforcing their rule that actionsheets should not be subclassed as I'm getting this error message - " : CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update." – Stu P. Sep 30 '13 at 22:47
7

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

Angelo
  • 533
  • 5
  • 18
6

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.

Community
  • 1
  • 1
RachelD
  • 4,072
  • 9
  • 40
  • 68