自iOS7以来,Viewcontroller没有出现

时间:2013-09-22 17:06:25

标签: iphone ios7

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

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

在运行iOS7的iPhone上不会发生这种情况,它在iPad上工作正常,但方法略有不同,但它似乎只是iPhone上的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];

1 个答案:

答案 0 :(得分: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];
        }

    }     }