在iOS 5和iOS 6中捕获不同的MKMapView截图? [英] Capture MKMapView screenshot different in iOS 5 and iOS 6?

查看:115
本文介绍了在iOS 5和iOS 6中捕获不同的MKMapView截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得mapview的截图。所以我用下面的代码。此代码在ipad和模拟器中完美运行,但在ipod上运行不正常。 iPad有iOS 6.0,我的xcode是4.2.1,iPod有iOS 5.0。

I would like to get screenshot of mapview. So i used following code. This code works perfectly in ipad and simulator but not on ipod. The iPad has iOS 6.0 and my xcode is 4.2.1 and the iPod has iOS 5.0.

- (UIImage*) renderToImage
{
    UIGraphicsBeginImageContext(mapView.frame.size);
    [mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext(); 
    return viewImage;
}

问题是,我在iPad,iPod和模拟器中有相同的图像但是不是名字相应的手动屏幕截图和编程屏幕截图。在iPod中名称非常大,同时在iPad和模拟器中名称是正常的,而且在iPod中也有一些名称不可见。这就是我的问题。

The problem is, i have got same image in iPad, iPod ans simulator but not names corresponding manual screen capture and programatic screen capture.The names are very big in iPod, at the same time names are normal in iPad and simulator and also some names are invisible in iPod.That is the my problem.

以下图片为:

此图片属于iPod手动屏幕截图。

This image belongs to iPod manual screen capture.

这个图片属于iPod programatic screen capture。

This image belongs to iPod programatic screen capture.

我不知道问题出在哪里。请帮助我。

I don't know where the problem is. Please help me anyone.

推荐答案

问题是 UIGraphicsBeginImageContext(mapView.frame.size); 这里。我刚将其替换为 UIGraphicsBeginImageContextWithOptions(mapView.frame.size,NO,0.0); 。然后它在iOS 5.0中工作。

The problem is UIGraphicsBeginImageContext(mapView.frame.size); here. I have just replaced this to UIGraphicsBeginImageContextWithOptions(mapView.frame.size, NO, 0.0);. Then it is working in iOS 5.0.

这篇关于在iOS 5和iOS 6中捕获不同的MKMapView截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆