Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iOS视网膜显示的奇数重定尺寸和分辨率_Iphone_Ios_Objective C - Fatal编程技术网

Iphone iOS视网膜显示的奇数重定尺寸和分辨率

Iphone iOS视网膜显示的奇数重定尺寸和分辨率,iphone,ios,objective-c,Iphone,Ios,Objective C,目前,我正在为UITableView附件视图使用自定义图像。我使用此自定义图像将附件视图设置为imageview。如果我使用cell-arrow.png(15x15像素),它看起来非常像素化。但是,如果我使用cell-arrow.png(100x100 px),然后在代码中重新调整它的大小[见下文],那么它看起来会更好。为什么会这样 后续问题: 似乎已经确定,使用100x100px图像,然后将其缩小到15x15,在设备上看起来更好(特别是视网膜,还没有完全测试它

目前,我正在为UITableView附件视图使用自定义图像。我使用此自定义图像将附件视图设置为imageview。如果我使用cell-arrow.png(15x15像素),它看起来非常像素化。但是,如果我使用cell-arrow.png(100x100 px),然后在代码中重新调整它的大小[见下文],那么它看起来会更好。为什么会这样

后续问题:

似乎已经确定,使用100x100px图像,然后将其缩小到15x15,在设备上看起来更好(特别是视网膜,还没有完全测试它<4.0)接下来的问题是,为了提高分辨率,我可以将图像设置为多大的最大尺寸?例如,我测试了同一个cell-arrow.png图像的1024x1024版本,它看起来与我重新调整100x100 px图像大小时的图像相同

*用于重新调整图像大小的代码:*


通常,您应该使用与屏幕上使用的图像大小完全相同的图像。否则,您会将图像放大到软件,最终可能会导致像素错位和锐线模糊。请记住,从iOS 4开始,UIKit中的所有测量值均以UIKit点为单位,在视网膜显示器上为1pt=2px,在非视网膜显示器上为1pt=1px

因此,对于15pt×15pt图像视图,如果要同时瞄准视网膜和非视网膜设备,则需要两个图像文件:

  • cell-arrow.png,15px×15px图像
  • 细胞-arrow@2x.png,一个30px×30px的图像

然后调用
[UIImage imageNamed:@“cell arrow”]
(注意缺少扩展名-UIKit会为您解决问题),操作系统将根据需要加载1x或2x版本。

您是否创建了另一个cell-arrow@2x.pngcell-arrow.png的图像比原始图像(30 x 30 px)大两倍?
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 15.0f, 15.0f);
    UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
    [myImage setImage:[UIImage imageNamed:@"cell-arrow.png"]];

   // cellArrowNotScaled ends up making the image look very pixelated
   // UIImageView *cellArrowNotScaled = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell-arrow15.png"]];

    cell.accessoryView = myImage; //cellArrowNotScaled;