2012-06-07 2 views
3

Button을 클릭하여 UIViewController 클래스 (이름은 CartViewController)에서 Appdelegate (이름은 SimpleDemoAppDelegate)로 이동하려고합니다. UIViewController에서 Appdelegate로 이동

버튼 IBAction를위한 방법 및 코드

내가도 너무
-(IBAction) Go 
{ 
    SimpleDemoAppDelegate *appdelegate=(SimpleDemoAppDelegate *)[UIApplication sharedApplication].delegate; 
    [self.navigationController presentModalViewController:appdelegate animated:YES]; 
} 

및과 pushViewController

을 시도

-(IBAction) Go 
{ 
    AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate; 
    UIViewController* presentingViewController = appDelegate.viewController; 
} 

이다, 그러나 경고를 보여줍니다.

호환되지 않는 포인터 타입 유형의 매개 변수에 'SimpleDemoAppDelegate의 *를'보내는 '의 UIViewController *'

나는이 경고가 표시 왜 누군가가 나에게 설명 할 수 있습니까?

+1

난 당신이 AppDelegate' 클래스'를 탐색 할 수 있다고 생각보고 쓰기 깜빡 생각합니다. 앱이 시작될 때 처음부터 호출되며 일반적으로 전역 변수 및 함수를 저장하는 데 사용됩니다. 클래스의 해당 메소드 및 변수를 호출합니다. –

+0

AppDelegate ...로 이동한다는 것은 무엇을 의미합니까? is [self.navigationController popToRootViewController];입니다. 너 exepecting 하나? –

+0

나는 또한 시도했다. ..SimpleDemoAppDelegate * obj = [[SimpleDemoAppDelegate alloc] init]; [self.navigationController pushViewController : obj animated : YES] –

답변

0

는 난 당신이 AppDelegate에의의 ViewController 속성이

SimpleDemoAppDelegate *appdelegate=(SimpleDemoAppDelegate *)[UIApplication sharedApplication].delegate; 
[self.navigationController presentModalViewController:appdelegate.viewController animated:YES]; 
관련 문제