Xcode错误超过5 UIImages

可能重复:
iPhone“,超过最多5个过滤专辑列表试图注册。 这将失败。“错误

当我通过Popover Controller或Modal View Controller向UIImageView添加图像时,在第四张图像之后,当我添加第五张时,Xcode的debugging器输出: “错误:超过最多5个过滤专辑列表试图注册。 “它仍然会让我添加5张以上的照片,但只有4张照片可以保存。 我在这里做了一些研究,发现这个问题: iOS 5 GM:<错误>:超过最多5个过滤专辑列表试图注册。 这将失败

这里的答案看起来好像是苹果的一个bug,而且应该被忽略。 那么,苹果通常会(修正)他们的Xcode bug,而且这个问题已经有一段时间了,所以我开始怀疑真正的原因是什么。 我认为这个错误是关系到我的应用程序只能保存多达4个图片。

以下是我正在使用的代码:

- (IBAction)grabImage { self.imgPicker = [[UIImagePickerController alloc] init]; self.imgPicker.delegate = self; self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { _popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker]; [_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } else { [self presentModalViewController:imgPicker animated:YES]; } [self.imgPicker resignFirstResponder]; } // Sets the image in the UIImageView - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { if (imageView.image == nil) { imageView.image = img; [self.array addObject:imageView]; [picker dismissModalViewControllerAnimated:YES]; [self.popover dismissPopoverAnimated:YES]; return; } if (imageView2.image == nil) { imageView2.image = img; NSLog(@"The image is a %@", imageView); [self.array addObject:imageView2]; [picker dismissModalViewControllerAnimated:YES]; [self.popover dismissPopoverAnimated:YES]; return; } if (imageView3.image == nil) { imageView3.image = img; [self.array addObject:imageView3]; [picker dismissModalViewControllerAnimated:YES]; [self.popover dismissPopoverAnimated:YES]; return; } if (imageView4.image == nil) { imageView4.image = img; [self.array addObject:imageView4]; [picker dismissModalViewControllerAnimated:YES]; [self.popover dismissPopoverAnimated:YES]; return; } if (imageView5.image == nil) { imageView5.image = img; [self.array addObject:imageView5]; [picker dismissModalViewControllerAnimated:YES]; [self.popover dismissPopoverAnimated:YES]; return; } } 

更新:这是我目前的代码:

 - (IBAction)grabImage { if (self.imgPicker == nil) { self.imgPicker = [[UIImagePickerController alloc] init]; } self.imgPicker.delegate = self; self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { _popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker]; [_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } else { [self presentModalViewController:imgPicker animated:YES]; } [self.imgPicker resignFirstResponder]; } 

从其他问题链接,这听起来像这是一个苹果的错误,但与创build多个UIImagePickerController有关。 您一次只能呈现一个图像select器控制器,所以也许您应该在第一次调用grabImage时创build一个,然后重复使用它,而不是每次都创build一个。