我可以用
MyFirstAppDelegate *delegate = (MyFirstAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.navigationController popViewControllerAnimated:YES];
或
[self.navigationController popViewControllerAnimated:YES];
那么两者有什么区别呢?
请回答我......
提前致谢..
最佳答案
当您从一个不是由导航 Controller 控制的 View Controller 的对象访问导航 Controller 时,您使用第一种形式。该表单通过拥有它的对象(即应用程序委托(delegate))访问导航 Controller 。由于可以从程序中的任何地方轻松调用应用程序委托(delegate),因此它是放置任何对象可能需要引用的东西的好地方。
您使用由导航 Controller 控制的 View Controller 中的第二种形式。它只能在之前被压入堆栈的 View Controller 中工作。
关于iphone - self.navigationController 和 delegate.navigationController 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2071397/