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

时间:2013-07-28 14:44:11

标签: ios objective-c

我正在使用此代码以编程方式切换视图控制器。当我构建并运行时,我收到此错误:@interface没有可见的ViewController声明选择器presentModalViewController:animated:completion:

代码:

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

如果我摆脱完成:nil然后我得到警告presentModalViewController:animated已被弃用:首先在iOS 6.0中弃用。我该怎么办?

2 个答案:

答案 0 :(得分:3)

问题是presentmodalviewcontroller:已弃用。请改用presentViewController:animated:completion:。你的代码:

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

答案 1 :(得分:-1)

-(void)alertview:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex{

     if (buttonIndex==1){
         UIViewController *newview = [[UIViewController alloc]init];
         [self presentedViewController:newview animated:YES completion:nil];
     }

}