iPad显示图像很大 - 但不应该

M4k*_*4ks 1 objective-c uiimageview ios

我为iPad 3开发了应用程序 - 带Retina显示屏.我根据规格计算出图像应该是1536 x 2008,以填充(使用状态栏)整个屏幕.我将图像重新调整为这样的尺寸,并以编程方式加载它并将其设置为在UIImageView上显示(从故事板加载).更重要的是,为了获得最佳性能,我将UIImageView模式设置为Center(以避免缩放).当我运行应用程序时,我只看到我的图像的中心 - 好像我的图像是屏幕的4倍 - 这不是真的.

她是我的viewWillAppear方法的代码

UIImage *image = [UIImage imageWithContentsOfFile: self.pageData.pageFilename];

NSLog(@"Image size: %f %f", [image size].width, [image size].height);

NSLog(@"Image view size: %f %f", self.imageView.frame.size.width, self.imageView.frame.size.height);

[ self.imageView setImage: image];
Run Code Online (Sandbox Code Playgroud)

我得到输出:

Image size: 1536.000000 1990.000000
Image view size: 768.000000 1004.000000
Run Code Online (Sandbox Code Playgroud)

怎么纠正这个?我的图像是你可以看到的尺寸的JPG和72 DPI - 但我确信DPI并不重要

Hub*_*ast 5

你正在混合像素和点.

在iOS中,尺寸以点数来衡量,而不是以像素为单位.如果设备使用视网膜显示,则1点= 2像素.使用旧显示器,您有1点= 1像素.


正常显示
1点= 1像素
1024*768点
1024*768像素

视网膜显示
1点= 2像素
1024*768点
2048*1536像素


因此,在这两种情况下,显示器的大小都相同:
1024*768点