2013-07-28 101 views
3

我使用此代碼以編程方式切換視圖控制器。當我建立和運行,我得到這個錯誤:ViewController無可見@interface宣佈選擇presentModalViewController:animated:completion:'ViewController'沒有可見的@interface聲明選擇器'presentModalViewController:animated:completion:'

代碼:

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

如果我擺脫完成的:無,然後我得到警告presentModalViewController:animated被棄用:首先在iOS 6.0中棄用。我該怎麼辦?

+2

[self.navigationController presentViewController:pSearchViewController動畫:是完成:無]; –

回答

3

問題是presentmodalviewcontroller:已棄用。改爲使用presentViewController:animated:completion:。您的代碼:

[self presentViewController:pSearchViewController animated:YES completion:nil]; 
-1
-(void)alertview:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex{ 

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

} 
相關問題