私はこのgithubイメージクロッパーを使用しています:https ://github.com/iosdeveloper/ImageCropper
この画像クロッパーでは、initメソッドに次の行があります。
CGRect rect;
rect.size.width = image.size.width;
rect.size.height = image.size.height;
[imageView setFrame:rect];
事前に、ポイントではなく画面の解像度に画像のサイズを変更します。そのため、コードをそのままにしておくと、奇妙な理由でUIImageがUIImageViewを埋めることができず、contentModesも調整しようとしました。
しかし、これ(画像クロッパーが含まれているUIPopoverのサイズ)に調整すると、次のようになります。
[imageView setFrame:CGRectMake(0, 0, 320, 480)];
UIImageはUIPopoverを埋めます。
本当の問題はここにあります: 画像の特定の部分にズームインして以下のコードを実行すると、画像をトリミングした場所の近くにないUIImageの左上部分のスクリーンショットが撮られます。それはscrollViewのzoomScaleに従いますが。
スクリーンショットコードは次のとおりです。
- (void)finishCropping {
float zoomScale = 1.0 / [scrollView zoomScale];
CGRect rect;
rect.origin.x = [scrollView contentOffset].x * zoomScale;
rect.origin.y = [scrollView contentOffset].y * zoomScale;
rect.size.width = [scrollView bounds].size.width * zoomScale;
rect.size.height = [scrollView bounds].size.height * zoomScale;
CGImageRef cr = CGImageCreateWithImageInRect([[imageView image] CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:cr];
CGImageRelease(cr);
[delegate imageCropper:self didFinishCroppingWithImage:cropped];
}
なぜこれが起こっているのか誰かが知っていますか?
ありがとう!