画像をキャプチャするには、向きも設定する必要があります。画像をディスクに保存するときは、使用する必要があります
writeImageToSavedPhotosAlbum:orientation:completionBlock:
機能し、そこにも正しい「方向」パラメーターを設定します。
使用法: https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/index.html#//apple_ref/occ/instm/ALAssetsLibrary/writeImageToSavedPhotosAlbum:orientation:completionBlock :
Objective C の例:
// Flash set to Auto for Still Capture
[CameraViewController setFlashMode:AVCaptureFlashModeAuto
forDevice:[[self videoDeviceInput] device]];
// Capture a still image.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo]
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer) {
self.imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
[[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:image.CGImage
orientation:(ALAssetOrientation)[image imageOrientation]
completionBlock:^(NSURL *assetURL, NSError *error) {
if(error == nil) {
NSLog(@"PHOTO SAVED - assetURL: %@", assetURL);
} else {
NSLog(@"ERROR : %@",error);
}
}];