我正在尝试从设备库中选择一张照片并在 UIImage 中设置,但是在用户从库中选择照片后设备崩溃:
这是崩溃日志:
Notice: Formulating crash report for process [7997]
Aug 8 10:16:36 iPad ReportCrash[8000] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Aug 8 10:16:36 iPad com.apple.launchd[1]
(UIKitApplication:[0x8dd8][7997]) <Warning>:
(UIKitApplication:[0x8dd8]) Job appears to have
crashed: Trace/BPT trap: 5
Aug 8 10:16:36 iPad backboardd[26] <Warning>: Application
'UIKitApplication:[0x8dd8]' exited abnormally with signal 5: Trace/BPT
trap: 5
这是我的代码:
-(IBAction)btnSelecionarFotoClick:(id)sender {
if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
inserindoFoto = YES;
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
[picker release];
}
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image editingInfo:(NSDictionary *)editingInfo {
NSData *dataObj = nil;
if (image) {
dataObj = UIImageJPEGRepresentation(image, 1.0);
}
if (imgUsuario.image) {
imgUsuario.image = nil;
[imgUsuario.image release];
}
imgUsuario.contentMode = UIViewContentModeScaleAspectFill;
imgUsuario.image = image;
[imgUsuario.layer setCornerRadius:5];
imgUsuario.layer.masksToBounds = YES;
[self dismissViewControllerAnimated:NO completion:nil];
inserindoFoto = NO;
}
编辑
如果我在不选择图片的情况下取消,也会崩溃:
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
[self dismissViewControllerAnimated:NO completion:nil];
}
我发现了问题:
如果我禁用 autoLayout 工作......但我需要使用 autoLayout