2

I want to set UIPIckerView height width dynamically in iphone.please give me idea for it.

Jignesh Patel
  • 755
  • 1
  • 8
  • 10

2 Answers2

2

Firstly you can change dynamically height and width of only UIPickerView Not UidatePicker so go with this code you will find out the way :-

    UIPickerView *picker = [[UIPickerView alloc] initWithFrame: CGRectZero];
    picker.showsSelectionIndicator = YES;
    picker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    CGSize ps = [picker sizeThatFits: CGSizeZero];
    picker.frame = CGRectMake(0.0, 0.0, ps.width, ps.height + 100);
Arpit Kulsreshtha
  • 2,452
  • 2
  • 26
  • 52
1

If you are unable to change the frame, check your autoLayout for constant width. If you are not using autoLayout disable it. By default pickerView has flexibleWidth resizingMask. .

You can adjust the width, but height is restricted to not less than 162.0f. Even if you try it won't resize. You will get following error invalid height value 50.0 pinned to 162.0

Anupdas
  • 10,211
  • 2
  • 35
  • 60