Fotoğraf Kitaplığı'na görüntüleri göndermek için -writeImageToSavedPhotosAlbum
kullanıyorum. Benim sahip olduğum problem, bir yönelimi belirtmesine rağmen, görüntülerin yanlış yönelimler ile sonuçlanmasıdır. AslındaNeden -writeImageToSavedPhotosAlbum resmimi yanlış yönlendiriyor?
Öyle görülüyor ki, AVCaptureVideoOrientationPortraitUpsideDown
, ve AVCaptureVideoOrientationLandscapeLeft
sonuna kadar AVCaptureVideoOrientationLandscapeRight
ve tersi gibi bakıyor gibi bakıyor AVCaptureVideoOrientationPortrait
ucunu yukarı dönük olanlar.
Bunun olmasının bir nedeni var mı? Bazı ek ayrıntılar şunlardır:
hiçbir ViewController benim görünümü için otomatik yön değişikliğini yapıyor sahiptir.
Tüm resimler AVCaptureVideoOrientationPortrait
eşit [image imageOrientation]
gösterir, ancak ben asıl yönelimi izlemek ve bağımsız -writeImageToSavedPhotosAlbum
geçmektedir.
kullanıyorum: Birisi bu bir kaç ışık kaynağı eğer -writeImageToSavedPhotosAlbum:orientation:completionBlock:
memnun olurum.
GÜNCELLEME: Bir UIImage nesnesini kaydetmek isterseniz
Ben belgelerinde okuduklarım rağmen,
, resim en bir CGImageRef almak için UIImage yöntemini CGImage kullanın ve yayın yapabilirsiniz image ALAssetOrientation.
devam ettim ve ben geçmek yönünü değiştirdi: bunlar manzara-haklısın sanki Şimdi
switch (lastOrientation) {
case UIDeviceOrientationPortrait:
default:
alOrientation = ALAssetOrientationUp;
break;
case UIDeviceOrientationPortraitUpsideDown:
alOrientation = ALAssetOrientationDown;
break;
case UIDeviceOrientationLandscapeLeft:
alOrientation = ALAssetOrientationLeft;
break;
case UIDeviceOrientationLandscapeRight:
alOrientation = ALAssetOrientationRight;
break;
}
[library writeImageToSavedPhotosAlbum:[image CGImage]
orientation:(ALAssetOrientation) alOrientation// [image imageOrientation]
completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"completion block");
}];
, bütün görüntüler, onların sol kenarı aşağı dönük olsun. Hala doğru değilim, ama en azından onları düzgün bir şekilde yönlendirdim.
Başka bir güncelleştirme:
Bu çalışır. Neden, bilmiyorum:
switch (lockedOrientation) {
case UIDeviceOrientationPortrait:
default:
alOrientation = ALAssetOrientationRight; //3 instead ofALAssetOrientationUp;
break;
case UIDeviceOrientationPortraitUpsideDown:
alOrientation = ALAssetOrientationLeft; //2 insted of ALAssetOrientationDown;
break;
case UIDeviceOrientationLandscapeLeft:
alOrientation = ALAssetOrientationUp; //0 instead of ALAssetOrientationLeft;
break;
case UIDeviceOrientationLandscapeRight:
alOrientation = ALAssetOrientationDown; //1 instead of ALAssetOrientationRight;
break;
}
[library writeImageToSavedPhotosAlbum:[image CGImage]
orientation:(ALAssetOrientation) alOrientation// [image imageOrientation]
completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"completion block");
}];
Son kod snippet'inde "lockedOrientation" nedir? – ebi