presentModalViewController:已弃用动画

poi*_*rez 11 xcode upgrade ios ios6

我在XCode中收到警告:

'presentModalViewController:animated:' is deprecated: first deprecated in iOS 6.0
Run Code Online (Sandbox Code Playgroud)

在这行代码上:

[self presentModalViewController:initialSettingsVC animated:YES];
Run Code Online (Sandbox Code Playgroud)

我尝试按照文档中的建议替换它:

[self presentModalViewController:initialSettingsVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我现在在XCode中遇到错误:

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

有任何想法吗?

Nir*_*iya 12

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

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

我在这里找到了


小智 6

更换

[self presentModalViewController:initialSettingsVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

[self presentViewController:reader animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)


Vin*_*zzz 4

您想使用以下内容

- (void)presentViewController:(UIViewController *)viewControllerToPresent 
                      animated: (BOOL)flag completion:(void (^)(void))completion;
Run Code Online (Sandbox Code Playgroud)

设置UIModalPresentationStyleUIModalTransitionStyleforviewController以获得您正在寻找的模态动画/演示