presentModalViewController:已弃用动画

时间:2013-06-11 15:10:56

标签: ios xcode ios6 upgrade

我在XCode中收到警告:

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

在这行代码上:

[self presentModalViewController:initialSettingsVC animated:YES];

我尝试按照documentation中的建议将其替换为:

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

我现在在XCode中遇到错误:

  

'ViewController'没有可见的@interface声明选择器   'presentModalViewController:动画:完成:

有什么想法吗?

3 个答案:

答案 0 :(得分:12)

使用以下........

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

我找到了Here

答案 1 :(得分:6)

替换

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

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

答案 2 :(得分:4)

您想使用以下

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

UIModalPresentationStyle设置UIModalTransitionStyleviewController以获取您正在寻找的模态动画/演示文稿