I am building an app in which you can make pictures or pick an image from the camera roll and save these inside the app to be displayed in a tableview and detailview. The problem is that when I make a picture from inside the app and save it, the tableview and detailview get terribly slow as if the app is freezing. I also get this error ": CGAffineTransformInvert: singular matrix.". When I load a picture from the camera-rol that was not taken from inside my app, there is no problem and the app runs very smouthly.
This is the code for when I open the camera and camera roll:
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex == actionSheet.cancelButtonIndex) {
return;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
switch (buttonIndex) {
case 0:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
break;
case 1:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
break;
}
[self presentModalViewController:picker animated:YES];
}
This is where I save it to the camera roll and put the image in an imageView:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
UIImage *mijnImage;
if (CFStringCompare((__bridge_retained CFStringRef)mediaType, kUTTypeImage, 0)==kCFCompareEqualTo) {
mijnImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
mijnPlaatje_.image = mijnImage;
UIImageWriteToSavedPhotosAlbum(mijnImage, nil, nil, nil);
}
[picker dismissModalViewControllerAnimated:YES];
}
And here I save the image inside my app:
-(IBAction)save:(id)sender{
drankjes.plaatje = [mijnPlaatje_ image];
[self dismissModalViewControllerAnimated:YES];
}
What am I doing wrong?