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,206
  • 3
  • 30
  • 50
Rajesh M P
  • 477
  • 1
  • 10
  • 21

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,206
  • 3
  • 30
  • 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
  • 46,010
  • 16
  • 115
  • 137
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
  • 21,182
  • 26
  • 82
  • 121
0

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

Jarson
  • 123
  • 4