2012-06-26 6 views
0

목표 : 오버레이가있는지도 (MKOverlayView)의 스크린 샷과 특수 효과를 가져옵니다. 내가 무슨 짓을iOS의 이미지 인지도 오버레이의 프로그래밍 스크린 샷을 얻는 방법

:

나는지도보기, 수 있도록 OverlayView뿐만 아니라 주석보기 선물을 가지고있다. 이것은 모두 하나의 컨트롤러에 의해 처리됩니다.

나는 스크린 샷을 취할 애플에서 제공하는 코드를 사용하고

// 대상 크기의 그래픽 컨텍스트를 작성

// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration 

// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext 

CGSize imageSize = [[UIScreen mainScreen] bounds].size; 

if (NULL != UIGraphicsBeginImageContextWithOptions) 
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 
else 
    UIGraphicsBeginImageContext(imageSize); 

CGContextRef context = UIGraphicsGetCurrentContext(); 

// Iterate over every window from back to front 
for (UIWindow *window in [[UIApplication sharedApplication] windows]) 
{ 
    if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) 
    { 
     // -renderInContext: renders in the coordinate space of the layer, 
     // so we must first apply the layer's geometry to the graphics context 
     CGContextSaveGState(context); 
     // Center the context around the window's anchor point 
     CGContextTranslateCTM(context, [window center].x, [window center].y); 
     // Apply the window's transform about the anchor point 
     CGContextConcatCTM(context, [window transform]); 
     // Offset by the portion of the bounds left of and above the anchor point 
     CGContextTranslateCTM(context, 
           -[window bounds].size.width * [[window layer] anchorPoint].x, 
           -[window bounds].size.height * [[window layer] anchorPoint].y); 

     // Render the layer hierarchy to the current context 
     [[window layer] renderInContext:context]; 
     //for(self.mapView.overlayView.layer.) 
     //[self.mapView.overlayView.layer renderInContext:context];  
     // Restore the context 
     CGContextRestoreGState(context); 
    } 
} 

// Retrieve the screenshot image 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

문제는 그 위의 코드 라인 지도보기 및 주석보기의 스크린 샷을 가져옵니다. 오버레이보기가 없습니다.

내 오버레이보기 (MKOverlayView)를 명확히하기 위해 이미지입니다. 이것은 스크린 샷에 표시되지 않습니다. 나는 OpenGL을 사용하지 않았다. 기본 핀 인 주석보기를 볼 수 있지만 스크린 샷은 타일을 캡처 할 수 없습니다. 나는 오랫동안 그 일을 해왔다. 어떤 도움을 많이 주시면 감사하겠습니다! 감사! 여기

내 컨트롤러가

모습입니다 - >>

->> MKMapViewOBject 
     ->> MKMapViewOverlayView 
     ->> MKMapOverlay 
     ->> MKAnnotation 
     ->> MKAnnotationView 

그래서 난 내 renderInContext에 문제가 오전 MYCONTROLLER : 컨텍스트를?

추가 정보 :

내 오버레이보기

UIGraphicsPushContext(context); 
NSData* data = //get data 

if(data) 
{ 
    UIImage* img = [[UIImage alloc] initWithData:data]; 
    [img drawInRect:drawRect blendMode:kCGBlendModeNormal alpha:0.4 ]; 
    [img release]; 

} 

UIGraphicsPopContext(); 

답변

0

문제는 drawMapRect에 있던 타일 그리기 코드에 따라. drawMapRect는 다른 스레드로 맵을 오버레이 할 때 MKMapRect에 대해 다른 값으로 호출됩니다. 따라서 사과는 코드가 스레드로부터 안전하고 여러 다른 가시적 인 MapRect로 실행될 수 있기를 바랍니다.

주어진 MapRect, 즉 가시적 인 부분을 기반으로 오버레이를 만드는 중입니다.

+0

이미 모든 경로가 그려져있는 스크린 샷을 찍었습니까? – Slavcho