presentModalViewController:Animated is deprecated in ios6

前端 未结 5 1273
醉梦人生
醉梦人生 2020-12-07 14:19

I am using the following code for an image picker. But when I run it in the simulator, I have a memory leak and I get a warning about presentModalViewcontroller:animat

相关标签:
5条回答
  • 2020-12-07 14:56
    [[Picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    

    Instead of

     [[Picker parentViewControl] dismissModalViewControllerAnimated:YES];
    

    and

    [self presentViewController:picker animated:YES completion:nil];
    

    Instead of

    [self presentModalViewController:picker animated:YES];
    
    0 讨论(0)
  • 2020-12-07 15:12
    if ([self respondsToSelector:@selector(presentViewController:animated:completion:)])
    {
        [self presentViewController:objSignupViewController animated:^{} completion:nil];
    }
    else
    {
        [self presentModalViewController:objSignupViewController animated:YES];
    }
    
    0 讨论(0)
  • 2020-12-07 15:15

    Use this line & check:

    [self presentViewController:imagePicker animated:YES completion:nil];
    
    0 讨论(0)
  • 2020-12-07 15:15

    As Vishal mentioned

    [self presentViewController:imagePicker animated:YES completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
    

    make sure you have added "completion:nil" as well

    0 讨论(0)
  • 2020-12-07 15:15

    Use:

    [self presentViewController:imagePicker animated:YES completion:nil];
    

    And then for your dismissal modal use:

    [self dismissViewControllerAnimated:controller completion:nil];
    

    or

    [self dismissViewControllerAnimated:YES completion:nil];
    
    0 讨论(0)
提交回复
热议问题