3
我想通过点击按钮从UIViewController类(名称是CartViewController)导航到Appdelegate(名称是SimpleDemoAppDelegate)。从UIViewController导航到Appdelegate
按钮的方法和代码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'类。它被称为第一次启动应用程序时,通常用于存储全局变量和函数..只需调用这些方法和变量从任何类... –
你是什么意思导航到AppDelegate ...?是[self.navigationController popToRootViewController];你正在检查的那个? –
我也尝试过..SimpleDemoAppDelegate * obj = [[SimpleDemoAppDelegate alloc] init]; [self.navigationController pushViewController:obj animated:YES] –