0

Currently, these are my codes to create a picker view

genderPicker = [[UIPickerView alloc] 
                initWithFrame:CGRectMake(0, 244, 320, 270)];
genderPicker.delegate = self;
genderPicker.dataSource = self;
genderPicker.tag = 1;
genderPicker.showsSelectionIndicator = TRUE;  

The problem with this set of codes is that if the screen is scrollable, the picker would just stay in that exact co-ordinates and will not move along with the screen when I scroll.

Could anyone assist me in animating the picker so when I scroll it up/down, the picker will follow?

Thank you.

Naux
  • 86
  • 10
  • Add the picker as a subview to the scrollview, like `[self.view addSubView:genderPicker];`, and when you're not using ARC, `[genderPicker release];`. – ott-- Dec 25 '12 at 03:00

1 Answers1

0

When you are adding the picker, do not add it on self.view, instead add it on the scrollview.

For eg:-

[self.scrollview addSubView:genderPicker];

Here self.scrollview represents the scrollview. This will make sure that it moves along with the scrollview.

iDev
  • 23,310
  • 7
  • 60
  • 85