Hi, As title said, I create an UIPickerView to show in a UIViewController. In iPhone simulator all work (3.5" device and 4" device), but on real device (iPhone 5s) the data are showing on the left side and it's visible only a part of the data. I tried in debug mode and release mode. It doesn't seem the same problem described here: http://forums.xamarin.com/discussion/13038/uipickerview-fine-in-debugger-but-displays-wrong-on-ipad/p1 because the user has no problem if he use release mode.
My UIPicker use a subclass of a UIPickerViewModel. My code:
public class CodServicePickerModel : UIPickerViewModel { private List items;
private float heightForRow; private float widthForRow;
public CodServicePickerModel(List items, float widthForRow, float heightForRow) { this.items = items; this.heightForRow = heightForRow; this.widthForRow = widthForRow - 10f; }
public override int GetComponentCount (UIPickerView picker) { return 1; }
public override int GetRowsInComponent (UIPickerView picker, int component) { if (items == null || items.Count < 1) { return 1; } return items.Count; }
public override UIView GetView (UIPickerView picker, int row, int component, UIView view) {
if (view == null && component == 0) { view = new UIView (new RectangleF (0, 0, GetComponentWidth (picker, component), GetRowHeight (picker, row))); var labelCod = new UILabel (new RectangleF (10f, 0, view.Frame.Width - 10f, view.Frame.Height / 2)); labelCod.TextColor = ViewConstant.getTextVeryDark (); ViewUtility.setSize (labelCod, ViewConstant.littleText); labelCod.Text = "Cod. Servizio " + items [row].codiceServizio; view.Add (labelCod); var labelIndirizzo = new UILabel (new RectangleF (10f, labelCod.Frame.Height, view.Frame.Width - 10f, view.Frame.Height / 2)); labelIndirizzo.TextColor = ViewConstant.getTextLightColor (); ViewUtility.setSize (labelIndirizzo, ViewConstant.microText); labelIndirizzo.Text = items [row].indirizzoCompleto; view.Add (labelIndirizzo); } return view;
}
public override float GetRowHeight (UIPickerView picker, int component) { return heightForRow; }
public override float GetComponentWidth (UIPickerView picker, int component) { if (component == 0) { return widthForRow; } return 0; } }
Any ideas?