3

我正在尝试通过单击按钮从 UIViewController 类(名称为 CartViewController)导航到 Appdelegate(名称为 SimpleDemoAppDelegate)。

IBAction on button的方法和代码是

-(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 也是,但它显示警告。

不兼容的指针类型将“SimpleDemoAppDelegate *”发送到“UIViewController *”类型的参数

有人可以向我解释为什么我看到这个警告吗?

4

1 回答 1

0

i think you forgot to write viewcontroller property of appDelegate see this

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