iOS10 相册图片二维码识别

#1、问题描述:
在iOS8,iOS9下,打开相册里的图片识别二维码功能正常,但在iOS10下,该功能失效。

打开相册代码:

- (void)openImagePicker {
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }

    UIImagePickerController *pickerVC = [[UIImagePickerController alloc] init];
    pickerVC.delegate = self;
    pickerVC.allowsEditing = NO;
    pickerVC.sourceType = sourceType;
    [self presentViewController:pickerVC animated:YES completion:nil];
    
}

识别二维码:

+ (NSString *)readQRCodeImage:(UIImage *)imagePicked {
    CIImage *qrcodeImage = [CIImage imageWithCGImage:imagePicked.CGImage];
    CIContext *qrcodeContext = [CIContext contextWithOptions:nil];
    
    //检测图片中的二维码,并设置检测精度为高
    CIDetector *qrcodeDetector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:qrcodeContext options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];
    
    //读取图片的qrcode特性
    NSArray *qrcodeFeatures = [qrcodeDetector featuresInImage:qrcodeImage];
    
    //返回的结果,只读取一条
    NSString *qrcodeResultString = nil;
    if (qrcodeFeatures && qrcodeFeatures.count > 0) {
        for (CIQRCodeFeature *qrcodeFeature in qrcodeFeatures) {
            if (qrcodeResultString && qrcodeResultString.length > 0) {
                break;
            }
            qrcodeResultString = qrcodeFeature.messageString;
        }
    }
    NSLog(@"%@",qrcodeResultString);
    
    return qrcodeResultString;
}

在iOS10下提示错误:

[qrcodeDetector featuresInImage:qrcodeImage];   

解决办法:设置相册图片为可编辑属性,即可解决此问题

pickerVC.allowsEditing = Yes;

#2.iOS10下相关权限适配:

在Info.plist中添加字段

Privacy - Camera Usage Description             打开相机   
Privacy - Photo Library Usage Description      打开相册   

状态栏实时显示,隐藏及改变样式

#1、隐藏状态栏方式:
->1.

-(BOOL)prefersStatusBarHidden{
    return YES;
}

->2.

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];   

#2、状态栏setStatusBarHidden 设置无效解决办法:
在plist添加字段 View controller-based status bar appearance 为NO

如图:
图

#3、设置状态栏StatusBar颜色样式: ->1.

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

->2.

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

#4、设置闪屏时状态栏StatusBar颜色样式:

如图:
图

打开全局断点后,每次都会在main中断一下,但是不崩溃的问题

#1、打开全局断点运行时,总是会在在main中断一下的问题:

出现问题的原因:
删除了在工程中的字体文件,但是plist中没有删除对应字段。

解决办法:
删除plist中不存在的字体文件字段。

如图:
图

真机运行 错误总结

#1、真机运行,Xcode 提示错误:

“(null)” is of a model that is not supported by this version of Xcode. Please use a different device.

解决办法:
command+q 关闭Xcode ,重新打开Xcode即可。

CocoaPods 遇到的坑

一、找不到相关库

出现错误提示:

ld: library not found for -lPods-CocoaLumberjack`   

解决办法:
设置 Project -> Pods 下所有第三方库的 Build Active Architecture OnlyNO

参考地址:http://my.oschina.net/ioslighter/blog/382422

二、pod install 失败
出现错误提示:

[!] The `app [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `app [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

解决办法:
在Build Settings -> Other linker flags 位置,添加 $(inherited) 参数

三、pod install 提示缺少目标依赖target
解决办法:

修改前:

platform :ios, '7.0'
pod 'CocoaLumberjack','~> 2.3.0'

修改后:
在Podfile中添加

target 'TelinkBlueDemo' do
platform :ios, '7.0'
pod 'CocoaLumberjack','~> 2.3.0'
end

其中,TelinkBlueDemo为所在项目中,TARGETS配置里的工程名字
参考地址:http://www.tuicool.com/articles/e6VrieN

UUID 和 UDID 的区别

一. UUID (Universally Unique IDentifier)

UUID是Universally Unique Identifier的缩写,中文意思是通用唯一识别码.

同一设备上的不同应用的UUID是互斥的,即能在改设备上标识应用。

二. UDID (Unique Device Identifier)

UDID是Unique Device Identifier的缩写,中文意思是设备唯一标识

使用场景:在真机调试,ad hoc 打包过程中,常常会用到设备UDID .

UUID 官网资料:
地址:https://en.wikipedia.org/wiki/Universally_unique_identifier

其他资料地址:
地址:http://www.jianshu.com/p/9b6662a89d96