2

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

当我通过 Popover Controller 或 Modal View Controller 将图像添加到 UIImageViews 时,在第 4 个图像之后,当我去添加第 5 个图像时,Xcode 的调试器输出:“错误:超过最大 5 个过滤的专辑列表试图注册。这将失败. ” 它仍然可以让我添加 5 张以上的图片,但只保存其中的 4 张。我在这里对此进行了一些研究,发现了这个问题: iOS 5 GM: <Error>: More than maximum 5 个过滤的专辑列表试图注册。这将失败

这里的答案似乎是Apple的一个错误,应该忽略它。好吧,Apple 通常(有点)快速修复他们的 Xcode 错误,这已经存在了一段时间,所以我开始想知道真正的原因是什么。我认为此错误与我的应用程序仅保存最多 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];
}
4

1 回答 1

2

从链接的其他问题来看,这听起来像是一个 Apple 错误,但与创建多个UIImagePickerControllers. 您一次只提供一个图像选择器控制器,因此也许您应该在第一次调用时创建一个grabImage然后重用它,而不是每次都创建一个新的。

于 2012-04-15T06:35:02.130 回答