После многократного вызова UIImagePickerController устройство перезагружается - PullRequest
0 голосов
/ 31 декабря 2011

Я реализую делегат 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 голосов
/ 01 января 2012

Это работает в симуляторе iOS? Также вы выпускаете какой-либо из этих объектов или ARC делает это? Это может помочь.

...