1

I have one storyboard file for iPhone devices, and in one of the views there is a subview that contains a UIPickerView, and, when it runs on the iPhone 4 the UIPickerView is stuck at the bottom of the view as it should be, but when it comes to the iPhone 5, the UIPickerView appears a little above of the bottom of the screen.

If I fix the problem for the iPhone 5, the UIVPickerView won't appear completely when I run it on the iPhone 4. (half of it appears below the screen)

So is there a way to have the UIViewPicker well laid for both iphone 4 and 5 resolutions?

NOTE: I solved the issue by creating a completely new subview with the UIPickerView. Now it is well laid whatever the device is.

3 Answers3

0

When creating the picker, you need to use the size of the screen to determine the location. It seems like you are just putting in the coordinates for the y manually, which only works when using one screen size.

If your view that you are in is the same size as the screen, as it most likely is but may not be, you can do:

int y = self.view.frame.size.height;

and use that as the y-coordinate of your pickerView.

Otherwise, you can find the size of the screen by using:

[[UIScreen mainScreen] applicationFrame].size.width //if in portrait
//or
[[UIScreen mainScreen] applicationFrame].size.height //if in landscape

Then you have to subtract the height of the navigationController from that if you have one.

Jsdodgers
  • 5,253
  • 2
  • 20
  • 36
  • Thank for the answer, but I dont think that would work because the AutoLayOut doesnt let you to change the position of the subview. Anyway I´ve just solved the issue by deleting the old subview and creating another one, I dont know what was wrong but as long as it work Im fine – Potajedehabichuelas Mar 23 '13 at 00:27
  • Alright. I dont use auto layout so I wouldnt know about that. But as long as you got it to work! – Jsdodgers Mar 23 '13 at 00:47
0

If you're using autolayout, you should be able to change the constraints the picker uses to get it to stick to the bottom. Select the picker, click the "H"-shaped autolayout menu icon in the bottom right corner of the storyboard, and choose "Bottom Space to Superview". Then delete any constraints attaching the picker to the top of the screen. If that doesn't work, make sure that all of the picker's superviews have constraints to attach them to the bottom, too; you'll have to decide whether you want them to resize or slide down on an iPhone 5.

Becca Royal-Gordon
  • 17,541
  • 7
  • 56
  • 91
0

I fixed the issue. Not sure what was going wrong but I deleted the subview, then created a new one and added the UIPickerView. Surprisingly, now it is well laid whatever the device is.