Dismiss UIImagePickerController

后端 未结 4 2021

I have tried every variation of dismissing a UIImagePickerController with out any luck. What am i doing wrong.

- (IBAction)choosePhoto
{
    self.picker = [[         


        
相关标签:
4条回答
  • 2021-01-06 16:40

    Are you running iOS 6? If so, presentModalViewController: is deprecated and could be causing some unexpected results. Try using presentViewController:animated:completion: instead.

    But technically, here's all you should have to do:

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
    {
       [imagePicker dismissViewControllerAnimated:NO completion:nil];//Or call YES if you want the nice dismissal animation
    }
    
    0 讨论(0)
  • 2021-01-06 16:40

    For Swift use this:

    func imagePickerControllerDidCancel(picker: UIImagePickerController!) {
        picker.dismissViewControllerAnimated(true, completion: nil)
    }
    
    0 讨论(0)
  • 2021-01-06 16:45

    Try this line. It might work for you.

    [self.picker dismissModalViewControllerAnimated:NO];
    

    And for iOS 6 and later use this

    [self.picker dismissViewControllerAnimated:NO completion:nil];
    

    Also use this code to present your picker controller

    if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
        [self presentViewController:self.picker animated:YES completion:nil];
    } else {
        //To target iOS 5.0
        [self presentModalViewController:self.picker animated:YES];
    }
    
    0 讨论(0)
  • 2021-01-06 16:47

    For Swift 4:

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
            picker.dismiss(animated: true, completion: nil)
    }
    
    0 讨论(0)
提交回复
热议问题