1

I never used Interface Builder ever in my app, and don't think it is something good to do.

My app was already designed for iPad/iPad2 layout, without ever considering making it work on iPhone4/iPhone5/iPAD-mini. Now I want my app to work on all of them.

I think it would be extremely ugly to have 4+ layout the universal app, like this:

if(ipad or ipad2) 
 view.frame = CGRectMake(0,0,100,100);
else if(ipad-mini)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone4)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone5)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone6)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone7)
  view.frame = CGRectMake(0,0,100,100);

There should be only 2 layout ideally, but I don't know how to implement this way. Those fixed coordinates would not stretch on different screen sizes

if(ipad or ipad2 or ipad-mini) 
  view.frame = CGRectMake(0,0,100,100);
else if(iphone4 or iphone5 or iphone6 or iphone7)
  view.frame = CGRectMake(0,0,100,100);

How do I do a universal app in the best way?

4

2 回答 2

0

when you started building this app you should have done soemthing like this:

 view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;

and you change above options according to your needs.

and yes you would need different for ipad, iphone

于 2013-06-18T22:39:28.673 回答
0

首先,你的 iPhone 布局几乎肯定会与 iPad 大不相同。对于 iPad,所有不同的类型都具有相同的纵横比,因此您只需要担心带有视网膜的 iPad 的 @2x 图像。

但是,对于 iPhone,您拥有 iPhone 4/4s VS iPhone 5。此外,您的屏幕空间要小得多,因此您需要想办法在更小的空间内呈现相同的信息。这可以使用滚动视图、表格视图和在一个视图控制器中包含一部分信息来完成,您可以从另一个视图控制器切换到该视图控制器。

最后,我强烈推荐大多数情况下的界​​面生成器。它为您处理 iPhone 与 iPhone 5 的对比,以及纵向与横向的对比。它甚至会在旋转手机时自动为过渡设置动画。但是,有时,当您需要进行自定义绘图或我们的布局确实很难通过界面生成器获得时,最好以编程方式进行。在这种情况下,检查哪个设备的好方法是通过检查[[UIScreen mainScreen] applicationFrame]. 使用 iPad 的 1024x768、iPhone 的 320x480 或 iPhone 5 的 320x568 的值进行检查。

但是,您确实应该使用界面构建器(对于大多数情况)。为什么你要避免它?

于 2013-06-18T22:53:29.757 回答