【问题标题】:iPhone and iPad screen resolutioniPhone 和 iPad 屏幕分辨率
【发布时间】:2013-02-23 05:26:12
【问题描述】:

我正在开发一个通用应用程序。我想知道 iPhone 的屏幕分辨率 (320 * 480) 和 iPad 中的 (768 *1024) 是否适用于所有 iphone(iPhone 3g、iPhone4 等)和所有 iPad。因为基于这些屏幕分辨率,我在 iPhone 和 iPad 中设置 textField 和 UILabel 的宽度。这些是否适用于视网膜和非视网膜?

【问题讨论】:

    标签: iphone ipad


    【解决方案1】:

    Retina iPhone 和 iPad 使用与非 Retina 设备相同的坐标系。目前所有 iPad 的逻辑坐标空间都是 768x1024,除 iPhone 5 以外的所有 iPhone 的逻辑坐标空间都是 320x480。您的代码应该可以在 Retina 和非 Retina 设备上正常运行。

    在 iPhone 5 上,您的应用程序将在屏幕顶部显示黑条,除非您通过包含用于扩展屏幕分辨率的 Default.png 来告诉 iOS 您想要使用全屏。

    您可以使用[[UIScreen mainScreen] bounds] 检查屏幕分辨率。此值在 Retina 和非 Retina 设备上将相同。您可以通过检查[[UIScreen mainScreen] scale] 的值来检测Retina 设备;这里的值是每单位逻辑坐标空间的物理像素数(非 Retina 为 1.0,Retina 为 2.0)。

    【讨论】:

    • 是的,我为 iPad 和 320x480(为 iPhone)放置了相同的 768x1024。这意味着视网膜和非视网膜没有其他坐标。它在方向(纵向和横向)上有什么不同吗?那 iPhone5 呢? ?我应该再次更改代码的规格吗?
    • 这里有很多不同的问题。我建议您首先阅读 Apple 关于 UIViewController 的文档:developer.apple.com/library/ios/#documentation/uikit/reference/…,其中涵盖了许多此类主题。
    【解决方案2】:

    UIKit 和 CoreGraphics 使用点而不是像素。

    Retina 和非 Retina 设备的点数相同,但像素数不同。这意味着相同的点值在不同的设备上可能意味着不同的像素值。

    要回答您的问题,是的,相同的布局 UILabel 宽度将在视网膜和非视网膜设备上显示相同。

    来自 Apple 开发者文档:

    In iOS, all coordinate values and distances are specified using floating-point values in units referred to as points. The measurable size of a point varies from device to device and is largely irrelevant. The main thing to understand about points is that they provide a fixed frame of reference for drawing.

    查看 View Programming Guide 中的 Points vs. Pixels 部分: http://developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15

    【讨论】:

      【解决方案3】:

      您始终可以使用这些功能来获取操作系统并对界面执行所需的操作。

      var pattern:RegExp = /iphone5/i; 
      var str:String = Capabilities.os; 
      
      if (str.search(pattern)==0)
      {
          trace('iPhone5 Detected. Alter height.');
      }else{
         trace('No need to change dimensions if developing at 960x640');
      }
      

      【讨论】:

        猜你喜欢
        • 2016-06-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-25
        • 1970-01-01
        相关资源
        最近更新 更多