2012-09-18 20 views
8

Estoy tratando de cambiar la altura de PickerViewUIPickerView Altura no se puede cambiar

self.pickerView = [[UIPickerView alloc] init]; 
self.pickerView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); 

registro Xcode muestra el siguiente mensaje:

-[UIPickerView setFrame:]: invalid height value 274.0 pinned to 216.0 

¿Cómo puedo cambiar su altura?

+0

no se puede cambiar la altura de UIPickerView. –

+0

¡En iOS 9 todo ha cambiado! http://stackoverflow.com/a/35562894/8047 –

Respuesta

29

aquí son sólo threevalidheights para UIPickerView(162.0, 180.0 and 216.0).

Puede usar las funciones CGAffineTransformMakeTranslation y CGAffineTransformMakeScale para que quepan adecuadamente en el selector a su conveniencia.

Ejemplo:

CGAffineTransform t0 = CGAffineTransformMakeTranslation (0, pickerview.bounds.size.height/2); 
CGAffineTransform s0 = CGAffineTransformMakeScale  (1.0, 0.5); 
CGAffineTransform t1 = CGAffineTransformMakeTranslation (0, -pickerview.bounds.size.height/2); 
pickerview.transform = CGAffineTransformConcat   (t0, CGAffineTransformConcat(s0, t1)); 

El código anterior change la height de pickerview to half y re-position a la (Left-x1, Top-y1) posición exacta.

Consulte más here.

4

Hay solo tres alturas válidas para UIPickerView (162.0, 180.0 and 216.0).

More detail.

1

Sólo hay tres valores válidos 162.0, 180.0 y 216.0 para la altura del UIPicker. incluso si establece una altura diferente, establecerá la altura en una de estas tres alturas, que es la más cercana a su altura determinada.

0

Pruebe así. También busqué en Google tantos ejemplos y encontré este.

pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,250,320,230)];//to change the height 
pickerView.delegate =self; 
pickerView.dataSource =self; 
pickerView.showsSelectionIndicator = YES; 
[self.view addSubview:pickerView]; 
Cuestiones relacionadas