iphone - self.navigationController 和 delegate.navigationController 有什么区别

标签 iphone objective-c delegates uiviewcontroller uinavigationcontroller

我可以用

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/

相关文章:

Objective-C 10.10 NSApplication 委托(delegate)无法调用委托(delegate)类中定义的方法

iphone - 显示 UITableView 溢出?

ios - 等同于 CGRectIntersectsRect

ios - 将手势 UITapGestureRecognizer 添加到 UILabel 后应用程序崩溃

iphone - 如果我们没有启用 AirPrint 的打印机,如何从 iPhone App 测试打印?

ios - 为委托(delegate)保留和释放对象

iphone - Objective-C 中的委托(delegate)和通知

iphone - 如何在 AVPlayer 中播放完第一首歌曲后继续播放第二首歌曲

ios - iphone 中的可扩展 tableView

ios - 如何在 Apple Watch 上安装 App