0

Need to display 4 UIPickerView in ViewController.

How can i customise height?

Minimum height we can given is 162. Can i give 100 height for each UIPickerView? Is there any framework or example available?

Shekhar Gupta
  • 6,148
  • 3
  • 29
  • 50
Rajesh M P
  • 435
  • 1
  • 8
  • 20

4 Answers4

1

Try this:

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);
Shekhar Gupta
  • 6,148
  • 3
  • 29
  • 50
0

Try with following code, it may be work in you case:

self.MyPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];

For Other tips check This Answer

UIPicker sizing in landscape mode

Community
  • 1
  • 1
iPatel
  • 43,583
  • 14
  • 113
  • 135
0

For UIPickerView there are only three Height : 162,180,216. You can use CGAffineTransformMakeTranslation and CGAffineTransformMakeScale for properly fit to picker.

CGAffineTransform t;
CGAffineTransform s;
CGAffineTransform u;
UIPickerView *pickerview;

t = CGAffineTransformMakeTranslation (0, pickerview.bounds.size.height);
s = CGAffineTransformMakeScale (1.0,0.5);
u = CGAffineTransformMakeTranslation (0 ,pickerview.bounds.size.height);
pickerview.transform = CGAffineTransformConcat (t, CGAffineTransformConcat(s,u));

Here the above code changes the height of picker view.

Avi
  • 20,182
  • 23
  • 76
  • 114
0

If you don't mind clipping the ends, you can embed it inside of a smaller view, with clipping enabled.

Jarson
  • 123
  • 4