zoukankan      html  css  js  c++  java
  • 相册选原图倒置解决方案

    相册选原图倒置解决方案

    - (void)addMediaToUploadQueue:(ALAsset *)media {
        @autoreleasepool {
            ALAssetRepresentation *defaultRepresentation = [media defaultRepresentation];
            CGImageRef fullResolutionImage = [defaultRepresentation fullResolutionImage];
    
            // Return if the user is trying to upload an image which has already been uploaded
            CGFloat scale = [defaultRepresentation scale];
            UIImageOrientation orientation = [defaultRepresentation orientation];
    
            UIImage *i = [UIImage imageWithCGImage:fullResolutionImage scale:scale orientation:orientation];
            if (![self isImageUnique:i]) return;
    
            NSDictionary *imageDictionary = [self dictionaryForAsset:media withImage:i];
    
            dispatch_async(self.background_queue, ^{
                NSManagedObjectContext *ctx = [APPDELEGATE createManagedObjectContextForThread];
                [ctx setUndoManager:nil];
    
                [ctx performBlock:^{
                    ImageEntity *newImage = [NSEntityDescription insertNewObjectForEntityForName:@"ImageEntity"
                                                                        inManagedObjectContext:ctx];
    
                    [newImage updateWithDictionary:imageDictionary
                             inManagedObjectContext:ctx];
    
                    [ctx save:nil];
    
                    [APPDELEGATE saveContext];
    
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [self.fetchedResultsController performFetch:nil];
                    });
    
                        if (!currentlyUploading) {
                            currentlyUploading = YES;
                            [self uploadImage:newImage];
                        }
                }];
            });
        }
    }
    
  • 相关阅读:
    多线程交替打印示例
    单列集合框架体系Collection
    同域名下,两个网站通过cookie共享登录注册功能大概思路。
    CSS 隐藏滚动条
    Vue3--组件间传值
    TypeScript--类(class)
    TypeScript--泛型(generic)
    理解LDAP与LDAP注入
    CRLF injection 简单总结
    pigctf期末测评
  • 原文地址:https://www.cnblogs.com/nonato/p/4469568.html
Copyright © 2011-2022 走看看