MKOverlayView を使用して、png 画像をカスタム マップとして追加しようとしています。私はほとんどそこにいます - 画像を適切な場所に並べることができ、MKOverlayView のサブクラスの -drawMapRect: メソッドが定期的に呼び出されていることを知っています。画像を適切にレンダリングできないようです。それは完全にぼやけていて、ほとんど認識できません。また、画像が十分に大きいこともわかっています (1936 × 2967)。-drawMapRect のコードは次のとおりです。
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{
// Load image from applicaiton bundle
NSString* imageFileName = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"map.jpg"];
CGDataProviderRef provider = CGDataProviderCreateWithFilename([imageFileName UTF8String]);
CGImageRef image = CGImageCreateWithJPEGDataProvider(provider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
// save context before screwing with it
CGContextSaveGState(context);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetAlpha(context, 1.0);
// get the overlay bounds
MKMapRect theMapRect = [self.overlay boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
// Draw image
CGContextDrawImage(context, theRect, image);
CGImageRelease(image);
CGContextRestoreGState(context);
誰が何が起こっているのか手がかりを持っていますか?
ありがとう!-マット