日常问题总结

日常问题总结

遇到SDWebImage (~> 4.0.0)required byPodfile`

工程Target-General-Deployment Target 需要设置运行对应的系统最低版本,如最低要求iOS8.0>

Xcode9 FFmpeg AVMediaType与系统的AVFoundation框架冲突

报错信息:Typedef ‘AVMediaType’ cannot be referenced with a enum specifier xxx….
解决方法:将FFmpeg的源码中的AVMediaType改个名字之后重新编译FFmpeg再导入工程即可编译通过。
打开终端 cd到FFMpeg源码路径,执行命令
sed -i ” “s/AVMediaType/FFMAVMediaType/g” grep -rl AVMediaType ./ffmpeg-* 然后重新编译即可>

UIImage与CVPixelBufferRef转换

- (CVPixelBufferRef) pixelBufferFromCGImage: (CGImageRef) image
{
    NSDictionary *options = @{
                              (NSString*)kCVPixelBufferCGImageCompatibilityKey : @YES,
                              (NSString*)kCVPixelBufferCGBitmapContextCompatibilityKey : @YES,
                              };

    CVPixelBufferRef pxbuffer = NULL;
    CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, CGImageGetWidth(image),
                                          CGImageGetHeight(image), kCVPixelFormatType_32ARGB, (__bridge CFDictionaryRef) options,
                                          &pxbuffer);
    if (status!=kCVReturnSuccess) {
        NSLog(@"Operation failed");
    }
    NSParameterAssert(status == kCVReturnSuccess && pxbuffer != NULL);

    CVPixelBufferLockBaseAddress(pxbuffer, 0);
    void *pxdata = CVPixelBufferGetBaseAddress(pxbuffer);

    CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(pxdata, CGImageGetWidth(image),
                                                 CGImageGetHeight(image), 8, 4*CGImageGetWidth(image), rgbColorSpace,
                                                 kCGImageAlphaNoneSkipFirst);
    NSParameterAssert(context);

    CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image),
                                           CGImageGetHeight(image)), image);
    CGColorSpaceRelease(rgbColorSpace);
    CGContextRelease(context);

    CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
    return pxbuffer;
}

-(UIImage*)pixelBufferToImage:(CVPixelBufferRef) pixelBuffer
{
    CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];
    CIContext *temporaryContext = [CIContext contextWithOptions:nil];
    CGImageRef videoImage = [temporaryContext
                             createCGImage:ciImage
                             fromRect:CGRectMake(0, 0,
                                                 CVPixelBufferGetWidth(pixelBuffer),
                                                 CVPixelBufferGetHeight(pixelBuffer))];

    UIImage *uiImage = [UIImage imageWithCGImage:videoImage];
    CGImageRelease(videoImage);
    return uiImage;
}

presentViewController方法延迟问题

在项目中遇到presentViewController方法弹出时间有明显的延迟,比用push慢很多,解决办法是在presentViewController时用线程处理添加
dispatch_async(dispatch_get_main_queue(),^{
//[self presentViewController:NavigationController animated:YES completion:nil];
});>

阅读更多
文章标签: xcode ios
个人分类: iOS技术
想对作者说点什么? 我来说一句

10.6日常总结

日常总结

leader_one leader_one

2017-10-13 22:18:57

阅读数:71

没有更多推荐了,返回首页

不良信息举报

日常问题总结

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭