1

MKMapView のスクリーンショットを取得しようとしています。

そして、私は次のコードを使用しています:

UIGraphicsBeginImageContext(myMapView.frame.size);

[myMapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return screenShot;

そして、地図の現在の場所のアイコンとGoogleのロゴが入ったほぼ空白の画像が表示されます。

何が原因でしょうか?

myMapView は実際には別の viewController のビュー上にあることをお伝えする必要がありますが、場所と Google ロゴを示す青いスポットが表示されているので、私が持っている参照は正しいものだと思います。

ありがとうございました。

4

2 に答える 2

2

ここで述べたように、これを試すことができます

- (UIImage*) renderToImage
{
   UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
   [self.layer renderInContext:UIGraphicsGetCurrentContext()];
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext(); 
  return image;
}
于 2012-04-30T14:14:12.407 に答える