presentModalViewController:animated is deprecated

32,342

Solution 1

Use following........

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
    [self presentViewController:test animated:YES completion:nil];
} else {
    [self presentModalViewController:test animated:YES];
}

i found Here

Solution 2

Replace

[self presentModalViewController:initialSettingsVC animated:YES completion:nil];

To

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

Solution 3

You want to use the following

- (void)presentViewController:(UIViewController *)viewControllerToPresent 
                      animated: (BOOL)flag completion:(void (^)(void))completion;

settting UIModalPresentationStyle and UIModalTransitionStyle for viewController in order to get the modal animation /presentation you're looking for

Share:
32,342
poiuytrez
Author by

poiuytrez

Updated on April 19, 2020

Comments

  • poiuytrez
    poiuytrez about 4 years

    I am getting a warning in XCode:

    'presentModalViewController:animated:' is deprecated: first deprecated in iOS 6.0
    

    on this line of code:

    [self presentModalViewController:initialSettingsVC animated:YES];
    

    I tried to replace it as suggested in the documentation with:

    [self presentModalViewController:initialSettingsVC animated:YES completion:nil];
    

    I now get an error in XCode:

    No visible @interface for 'ViewController' declares the selector 'presentModalViewController:animated:completion:'

    Any ideas?