I have a UIImagePickerController which I show in a popover when the user clicks a button. This works fine in the iPad simulator, but when I try to do the same on a real test device, I get NSRangeExceptionin the alloc / init line for my selection of images!
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) (kUTTypeImage), nil];
Here is the error message:
* Application termination due to an uncaught exception 'NSRangeException', reason: '* - [NSOrderedSet initWithOrderedSet: range: copyItems:]: range {8, 1} goes beyond [0 .. 0]'
I determined that it was the exact line trying to step over the line in debug mode and step over this particular line - this is what causes the exception.
EDIT:
, 100%, , iOS, - .
- . . , xib-based
- iPad xib/,
IBAction viewcontroller. pickerPopoverController __strong ivar
-(void)iMakeItCrash:(UIButton*)sender
{
UIImagePickerController* ip = [[UIImagePickerController alloc] init];
ip.delegate = self;
ip.allowsEditing = YES;
ip.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
ip.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) (kUTTypeImage), nil];
pickerPopoverController = [[UIPopoverController alloc] initWithContentViewController:ip];
[pickerPopoverController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
IBAction Touch Up Inside.
- , iPad
EDIT2:
, presentPopoverFromBarButtonItem:. , , ...