Capture MKMapView screenshot different in iOS 5 and iOS 6?

时间秒杀一切 提交于 2019-12-08 12:31:12

问题


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;
}

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.

The following images are:

This image belongs to iPod manual screen capture.

This image belongs to iPod programatic screen capture.

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


回答1:


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.




回答2:


You can tell by looking at the app in each situation, it's not your screenshot code that is magically creating different maps, the underlying maps are different.



来源:https://stackoverflow.com/questions/13834838/capture-mkmapview-screenshot-different-in-ios-5-and-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!