多次调用UIImagePickerController后,设备重新启动

时间:2011-12-31 19:29:41

标签: iphone crash uiimage uiimagepickercontroller restart

我实现了UIImagePickerController委托,UINavigationController委托,UIPopOverController委托。我不知道问题是什么。调用3次,4次或5次后,我的设备重新启动(每次构建都不同)。请帮帮我解决!!

编辑:我收到此错误:

More than maximum 5 filtered album lists trying to register. This will fail.

这是我用来调用UIImagePickerController并获取图像的代码:

- (IBAction)imgPickerPressed:(id)sender {
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
        imgPickerTypeActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose image source:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Photo Library", nil];
        [imgPickerTypeActionSheet showInView:self];
    }
    else {
        UIImagePickerController *controller = [[UIImagePickerController alloc] init];
        [controller setDelegate:self];
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
            [controller setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        }
        imgPickerPopOver = [[UIPopoverController alloc] initWithContentViewController:controller];
        imgPickerPopOver.delegate = self;
        [imgPickerPopOver presentPopoverFromRect:CGRectMake(imgPickerButton.frame.origin.x, imgPickerButton.frame.origin.x-250, 0.0, 0.0) 
                                          inView:self
                        permittedArrowDirections:UIPopoverArrowDirectionDown 
                                        animated:YES];
    }
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if ([actionSheet isEqual:imgPickerTypeActionSheet]) {
        if (buttonIndex == 0) {
            UIImagePickerController *controller = [[UIImagePickerController alloc] init];
            [controller setDelegate:self];
            [controller setSourceType:UIImagePickerControllerSourceTypeCamera];

            [[delegate getVC] presentModalViewController:controller animated:YES];
        }
        if (buttonIndex == 1) {
            UIImagePickerController *controller = [[UIImagePickerController alloc] init];
            [controller setDelegate:self];
            [controller setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

            imgPickerPopOver = [[UIPopoverController alloc] initWithContentViewController:controller];
            imgPickerPopOver.delegate = self;
            [imgPickerPopOver presentPopoverFromRect:CGRectMake(imgPickerButton.frame.origin.x, imgPickerButton.frame.origin.x-250, 1, 1) 
                                              inView:self
                            permittedArrowDirections:UIPopoverArrowDirectionDown 
                                            animated:YES];
        }
    }
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    [imgPickerPopOver dismissPopoverAnimated:YES];
    pickedImageView.image = image;
    [self valueChanged:nil];
}

1 个答案:

答案 0 :(得分:0)

这是否适用于iOS模拟器?你也发布了这些物品,还是ARC做的? This可能有帮助。