11

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?

Community
  • 1
  • 1
poiuytrez
  • 21,330
  • 35
  • 113
  • 172

3 Answers3

11

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

Community
  • 1
  • 1
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
6

Replace

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

To

[self presentViewController:reader animated:YES completion:nil];
Praveen
  • 55,303
  • 33
  • 133
  • 164
Ahmed Talaab
  • 121
  • 2
  • 8
4

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

Praveen
  • 55,303
  • 33
  • 133
  • 164
Vinzzz
  • 11,746
  • 5
  • 36
  • 42