- Я получаю захваченное изображение и конвертирую его в NSData следующим образом:
< /ол>Код: Выделить всё
UIImage *source = info[UIImagePickerControllerOriginalImage]; NSData *imageData = UIImageJPEGRepresentation(source, 1.0);
- Затем я сохраняю данные изображения во временный каталог, например:
Я получаю успех как true, что означает, что изображение сохраняется по указанному пути.Код: Выделить всё
NSString *directoryPath = NSTemporaryDirectory(); NSString *filePath = [directoryPath stringByAppendingPathComponent:@"CapturedImageFromCamera.jpg"]; NSError *error = nil; BOOL success = [imageData writeToFile:filePath options:NSDataWritingAtomic error:&error];
- Я создаю QLThumbnailGenerationRequest следующим образом:
Код: Выделить всё
CGSize thumbnailSize = CGSizeMake(720, 720);
QLThumbnailGenerator *generator = [[QLThumbnailGenerator alloc] init];
QLThumbnailGenerationRequest *request = [[QLThumbnailGenerationRequest alloc] initWithFileAtURL: [NSURL fileURLWithPath:filePath] size:thumbnailSize scale:[UIScreen mainScreen].scale representationTypes:QLThumbnailGenerationRequestRepresentationTypeThumbnail];
[generator generateBestRepresentationForRequest:request completionHandler:^(QLThumbnailRepresentation * _Nullable thumbnail, NSError * _Nullable error) {
if (error) {
NSLog(@"ERROR = %@", error.localizedDescription);
} else {
NSLog(@"SUCCESS");
}
}];
Код: Выделить всё
Thumbnail generation failed with error: The operation couldn’t be completed. (QLThumbnailErrorDomain error 0.)
Error code: 0
Error domain: QLThumbnailErrorDomain
Error user info: {
NSUnderlyingError = "Error Domain=QLThumbnailErrorDomain Code=102 \"(null)\"";
Будем благодарны за любую помощь по этому поводу. Спасибо
Подробнее здесь: https://stackoverflow.com/questions/790 ... aptured-fr