ios presentModalViewController:animated 已弃用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17047578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:53:50  来源:igfitidea点击:

presentModalViewController:animated is deprecated

iosxcodeios6upgrade

提问by poiuytrez

I am getting a warning in XCode:

我在 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 documentationwith:

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

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

I now get an error in XCode:

我现在在 XCode 中遇到错误:

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

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

Any ideas?

有任何想法吗?

回答by Nirav Gadhiya

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

我在这里找到

回答by Ahmed Talaab

Replace

代替

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

To

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

回答by Vinzzz

You want to use the following

你想使用以下

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

settting UIModalPresentationStyleand UIModalTransitionStylefor viewControllerin order to get the modal animation /presentation you're looking for

setttingUIModalPresentationStyleUIModalTransitionStyle用于viewController为了得到你要寻找的模式动画/演示