iOS 10 - 应用程序崩溃通过UIImagePickerController访问照片库或设备相机 [英] iOS 10 - App crashes To access photo library or device camera via UIImagePickerController
问题描述
以下是我访问照片库的代码
- (无效)click_gallery
{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController * imgPicker = [[UIImagePickerController alloc] init];
UIColor * color = [UIColor colorWithRed:46.0 / 255绿色:127.0 / 255蓝色:244.0 / 255 alpha:1];
[imgPicker.navigationBar setTintColor:color];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imgPicker animated:NO completion:Nil];
}
}
并以
此应用尝试在没有使用说明的情况下访问隐私敏感数据。应用程序的Info.plist必须包含一个NSCameraUsageDescription键,其字符串值向用户解释应用程序如何使用此数据。
libsystem_kernel.dylib`__pthread_kill:
0x109955efc< + 0>:movl $ 0x2000148,%eax; imm = 0x2000148
0x109955f01< + 5>:movq%rcx,%r10
0x109955f04< + 8>:syscall
- > 0x109955f06< + 10>:jae 0x109955f10; 1 + 20 - ;
0x109955f08< + 12>:movq%rax,%rdi
0x109955f0b< + 15>:jmp 0x1099507cd; cerror_nocancel
0x109955f10< + 20>:retq
0x109955f11< + 21>:nop
0x109955f12< + 22>:nop
0x109955f13< + 23>:nop
我得到主题10:EXC_BAD_INTRUCTION代码= exc_i386_invop ,
相同的代码在iOS 9中运行良好。有人可以帮我解决这个问题。在此先感谢。
在 iOS 10 中。您必须为相机和相机设置隐私设置。图片库。
相机:
键:隐私 - 相机使用说明
价值:$(PRODUCT_NAME)相机使用
照片图书馆:
密钥:隐私 - 照片库使用说明
价值:$(PRODUCT_NAME)照片使用
Below is my code to access photo library
-(void)click_gallery
{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *imgPicker= [[UIImagePickerController alloc] init];
UIColor* color = [UIColor colorWithRed:46.0/255 green:127.0/255 blue:244.0/255 alpha:1];
[imgPicker.navigationBar setTintColor:color];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imgPicker animated:NO completion:Nil];
}
}
And it aborts with
This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
libsystem_kernel.dylib`__pthread_kill:
0x109955efc <+0>: movl $0x2000148, %eax ; imm = 0x2000148
0x109955f01 <+5>: movq %rcx, %r10
0x109955f04 <+8>: syscall
-> 0x109955f06 <+10>: jae 0x109955f10 ; <+20>
0x109955f08 <+12>: movq %rax, %rdi
0x109955f0b <+15>: jmp 0x1099507cd ; cerror_nocancel
0x109955f10 <+20>: retq
0x109955f11 <+21>: nop
0x109955f12 <+22>: nop
0x109955f13 <+23>: nop
And I get Thread 10:EXC_BAD_INTRUCTION code=exc_i386_invop, Same code was working fine in iOS 9. Can someone help me to solve this issue. Thanks in Advance.
In iOS 10. You have to set privacy Setting for Camera & Photo Library.
Camera :
Key : Privacy - Camera Usage Description
Value : $(PRODUCT_NAME) camera use
Photo Library:
Key : Privacy - Photo Library Usage Description
Value : $(PRODUCT_NAME) photo use
这篇关于iOS 10 - 应用程序崩溃通过UIImagePickerController访问照片库或设备相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!