11

我在 XCode 中收到警告:

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

在这行代码上:

[self presentModalViewController:initialSettingsVC animated:YES];

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

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

我现在在 XCode 中遇到错误:

'ViewController' 没有可见的@interface 声明选择器'presentModalViewController:animated:completion:'

有任何想法吗?

4

3 回答 3

12

使用以下......

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

我在这里找到

于 2013-06-11T15:25:17.257 回答
6

代替

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

[self presentViewController:reader animated:YES completion:nil];
于 2013-12-11T13:44:15.890 回答
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

于 2013-06-11T15:15:29.467 回答