2个故事板和1个PickerView

时间:2012-10-08 03:50:06

标签: storyboard ios6 uipickerview iphone-5

我有2个故事板,一个用于iPhone 5,另一个用于4s / 4/3。我做了我的选择程序,我相应地定位它,所以它适合iphone 5使用此代码

 picker1 = [[UIPickerView alloc] initWithFrame:CGRectMake(13, 272.5, 294, 219
                                                        )];

但是当我在我的iPhone 4上运行它时它太低了我不想破坏我的iphone 5,因为我花了最后两天完善它的一切。有没有办法让iphone加载相同的选择器,但根据屏幕大小不同的大小和坐标,例如,如果屏幕== 568 .....其他....

?? 这是我的应用程序的最后一步。有任何线索如何完成这个?

1 个答案:

答案 0 :(得分:2)

这应该提供您所追求的目标:

CGRect iphone5frame = CGRectMake(13, 272.5, 294, 219);
CGRect iphone4frame = CGRectMake(13, 272.5, 294, 219); // Edit these values for the iPhone 4
picker1 = [[UIPickerView alloc] initWithFrame:([[UIScreen mainScreen] bounds].size.height <= 480.0 ? iphone4frame : iphone5frame)];

编辑:更新了更多自定义代码

相关问题