我正在尝试通过单击按钮从 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,但它显示警告。
不兼容的指针类型将“SimpleDemoAppDelegate *”发送到“UIViewController *”类型的参数
有人可以向我解释为什么我会看到这个警告吗?
最佳答案
我想你忘了写 appDelegate 的 viewcontroller 属性看到这个
SimpleDemoAppDelegate *appdelegate=(SimpleDemoAppDelegate *)[UIApplication sharedApplication].delegate;
[self.navigationController presentModalViewController:appdelegate.viewController animated:YES];
关于iphone - 从 UIViewController 到 Appdelegate 的导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10927295/