3

ボタンをクリックして、UIViewController クラス (名前は CartViewController) から Appdelegate (名前は SimpleDemoAppDelegate) に移動しようとしています。

ボタン上の IBAction のメソッドとコードは次のとおりです。

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

私も試してみました

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

と pushViewController も、しかし、それは警告を示しています。

タイプ「UIViewController *」のパラメーターに「SimpleDemoAppDelegate *」を送信する互換性のないポインタータイプ

この警告が表示される理由を説明してもらえますか?

4

1 に答える 1

0

appDelegate の viewcontroller プロパティを書き忘れたと思います これを見てください

SimpleDemoAppDelegate *appdelegate=(SimpleDemoAppDelegate *)[UIApplication sharedApplication].delegate;
[self.navigationController presentModalViewController:appdelegate.viewController animated:YES];
于 2012-06-07T07:20:00.053 に答える