0

编辑 - 我自己解决了这个问题 - 请参阅底部的注释

在 Xcode 5 上使用 iOS7 时,我使用一个选项从相机或照片库中拍摄图像,一旦选择了图像(或拍摄了一张新照片),视图应该翻转到下一个屏幕。

这在运行 iOS7 的 iPhone 上不会发生,它在 iPad 上运行良好,但方法略有不同,但它似乎是 iOS7 上唯一的 iPhone 问题。

这是使用的代码,例如,从库函数中选择图像;

-(void) choosePic {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
        UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
        cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
        cameraUI.allowsEditing = NO;
        cameraUI.delegate = self;

        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            _popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
            [_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


        }
        else

            [self presentModalViewController: cameraUI animated: YES];

    }    
}

此外,选择器完成后的代码;

- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { 
    //Disable buttons

    [[UIApplication sharedApplication] setStatusBarHidden:YES];

    [self disableButtons];

    //Get image
    self.originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage];

    //Dismiss
    if(_popover)
    {
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            [_popover dismissPopoverAnimated:YES];
            _popover = nil;
        }
    }
    else
        [picker dismissModalViewControllerAnimated: YES];

    //Next
    [self performSelector: @selector(nextScreen) withObject:nil afterDelay:0.5];
}

我通过切换解决了这个问题;

[picker dismissModalViewControllerAnimated: YES];

[picker dismissViewControllerAnimated:NO completion:nil];
4

1 回答 1

0

首先,您需要确保逻辑到达预期的正确位置,尝试在 iPhone 的特定行之前设置断点或 NSLog,试试这个(你也错过了花括号,在此处添加它们):

-(void) choosePic {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
        UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
        cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
        cameraUI.allowsEditing = NO;
        cameraUI.delegate = self;

        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            _popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
            [_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


        }else{
            NSLog(@"Checkpoint !");
            [self presentModalViewController: cameraUI animated: YES];
        }

    }     }
于 2013-09-22T17:10:39.623 回答