Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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
MKMapView renderInContext-iPhone 4(视网膜)问题_Iphone_Objective C_Ios - Fatal编程技术网

MKMapView renderInContext-iPhone 4(视网膜)问题

MKMapView renderInContext-iPhone 4(视网膜)问题,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个尺寸为64x64的MKMapView。我正在使用“renderInContext:”方法从地图视图创建图像。并将图像指定给UITableViewCell的imageView。在普通iPhone中,它显示的图像是正确的。但在iPhone(视网膜)中,它显示的图像模糊了。我是在模拟器中测试这个,而不是在实际设备中。我已附上下面的屏幕截图 左侧带圆角的缩略图是UITableViewCell的imageView。右侧的缩略图是MKMapView 我使用以下代码从地图视图中获取图像 UIGrap

我有一个尺寸为64x64的MKMapView。我正在使用“renderInContext:”方法从地图视图创建图像。并将图像指定给UITableViewCell的imageView。在普通iPhone中,它显示的图像是正确的。但在iPhone(视网膜)中,它显示的图像模糊了。我是在模拟器中测试这个,而不是在实际设备中。我已附上下面的屏幕截图

左侧带圆角的缩略图是UITableViewCell的imageView。右侧的缩略图是MKMapView

我使用以下代码从地图视图中获取图像

UIGraphicsBeginImageContext(CGSizeMake(64, 64));
CGContextRef context = UIGraphicsGetCurrentContext();
[[mapView layer] renderInContext:context];
thumbnail_image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

为什么iPhone(视网膜)会出现这种情况?如何解决此问题?

您能否提供一些示例代码(因为我真的很感兴趣您是如何做到这一点的,事实上,这对我来说是新的^^)
在类似的情况下,我创建了一个大小为两倍的图像,然后通过
UIImageView
自动缩小(将调整大小属性设置为适合所有边框)

编辑:但我认为它应该使
ScaleToFill
自动填充

UIGraphicsBeginImageContext(CGSizeMake(128, 128));    
…
myImageView.frame = CGRectMake(0, 0, 64, 64);
myImageView.contentMode = UIViewContentModeScaleToFill;
如a中所述:

使用带有选项的
UIGraphicsBeginImageContext,而不是
UIGraphicsBeginImageContext

UIGraphicsBeginImageContextWithOptions(CGSizeMake(64, 64), NO, 0.0);
有关更多详细信息,请参阅。它说:

注意:从iOS 4开始, UIGraphicsBeginImageContextWithOptions 允许您提供电子秤 因素比例因子为零将设置它 到设备的比例因子 主屏幕。这使您能够 最尖锐、最高的分辨力 显示的快照,包括 视网膜显示


如何设置resize属性?实际上,图像视图是UITableViewCell的imageView。请尝试以下回答:Hai Sir Gudevening,如何从mkmapview创建缩略图(75*75)图像?如上图所示…如果您有任何可能,请提供示例代码…谢谢。这是我给自己的一个提示,因为我一直在搜索这个问题,并感到困惑。在本例中,从UIGraphicsGetImageFromCurrentImageContext()返回的UIImage将是64x64,而不是您可能认为的128x128——UIImage(以及基础CGImage)具有一个附加的scale属性。我将图像放入GL纹理中,使用图像(点)大小,忘记了需要将其乘以比例才能得到像素尺寸。下次一定要记住,未来的我。