I want to set UIPIckerView height width dynamically in iphone.please give me idea for it.
Asked
Active
Viewed 5,741 times
2
Jignesh Patel
- 755
- 1
- 8
- 10
-
How do you want to resize, is there any constraints? – Anupdas Apr 19 '13 at 10:25
-
I want to set height = 50 and width= 50 but it does not change its size. – Jignesh Patel Apr 19 '13 at 11:43
-
Check my answer. There is a default size for pickerView you cannot reduce the height below that limit. – Anupdas Apr 19 '13 at 12:08
2 Answers
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