4

I'm using this code to switch view controllers programmatically. When I build and run, I get this error: No visible @interface for ViewController declares the selector presentModalViewController:animated:completion:

Code:

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

If I get rid of completion:nil then I get the warning presentModalViewController:animated is deprecated: first deprecated in iOS 6.0. What do I do?

4

2 回答 2

4

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

[self presentViewController:pSearchViewController animated:YES completion:nil];
于 2013-07-28T15:02:27.087 回答
-1
-(void)alertview:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex{

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

}
于 2015-02-25T11:29:35.950 回答