我有一个视图,其中有6个图像视图。我使用相机UIImagePickerController设置图像。每次我选择第3张图片时,我的应用程序总是崩溃,当我检查仪器时,没有泄漏。怎么了? 这是我的代码:
- (void)openCamera
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSData* imageData = UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], 0.0001f);
[self dismissViewControllerAnimated:true completion:nil];
if ([_selectedButton isEqualToString:@"headOffice"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgHeadOffice"];
//_imgHeadOffice = [UIImage imageWithData:imageData];
_imgViewHeadOffice.image = [UIImage imageWithData:imageData];
}
else if ([_selectedButton isEqualToString:@"siteOffice"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgSiteOffice"];
//_imgSiteOffice = [UIImage imageWithData:imageData];
_imgViewSiteOffice.image = [UIImage imageWithData:imageData];
}
else if ([_selectedButton isEqualToString:@"roadCondition"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgRoadCondition"];
//_imgRoadCondition = [UIImage imageWithData:imageData];
_imgViewRoadCondition.image = [UIImage imageWithData:imageData];
}
else if ([_selectedButton isEqualToString:@"vehicle"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgVehicle"];
//_imgVehicle = [UIImage imageWithData:imageData];
_imgViewVehicle.image = [UIImage imageWithData:imageData];
}
else if ([_selectedButton isEqualToString:@"installedTire"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgInstalledTire"];
//_imgInstalledTire = [UIImage imageWithData:imageData];
_imgViewInstalledTire.image = [UIImage imageWithData:imageData];
}
else if ([_selectedButton isEqualToString:@"tireScrap"])
{
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imgTireScrap"];
//_imgTireScrap = [UIImage imageWithData:imageData];
_imgViewTireScrap.image = [UIImage imageWithData:imageData];
}
}
这是我的仪器快照:
编辑: 应用程序在处理行崩溃
NSData* imageData = UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], 0.0001f);
我第三次拍照。
这是应用关闭时的日志
答案 0 :(得分:0)