Iphone 中的导航栏控制器后退按钮如何工作?
当我们点击导航控制器中的后退按钮时,它会自动弹出视图控制器并返回到上一个视图控制器。任何人都可以告诉我它是如何工作的。xcode 中该操作的代码在哪里。
When we click back button in navigation controller, it'll automatically pops the view controller and goes back to the previous view controller.. could anyone tell me how it's works.. where is the code for that action in xcode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
完成所有这些操作的代码是在 Apple 的 UINavigationController 类中处理的。你看不到这段代码。
如果您想更改 Apple 类的行为,它们有时会委托其执行的某些操作的责任,或者有时只是提供将要发生某事的信息。
例如,如果您的类成为 UINavigationController 的委托,它将向您发送两条消息:
The code which does all of that is handled in Apple's
UINavigationController
class. You don't get to see this code.If you want to change the behavior of Apple's classes they sometimes delegate responsibility for some of the actions they perform, or sometimes just provide information that something is going to happen.
For example if your class becomes the delegate of UINavigationController it will send you two messages:
我不知道你所说的“它是如何工作的”到底是什么意思。但是发生的情况是视图控制器被放置在一个堆栈中(RootController是导航控制器),当你按“后退”按钮时,它只是弹出最上面的控制器在堆栈中,您从原来的地方回来了。希望它有帮助..!!
I dont know what you exactly mean by "how it works"..but what happens is the view controllers are placed in a stack (RootController which is the Navigation controller) and when you press "back" button it simply pops the top most controller in the stack and you are back from where you came.Hope it helps..!!
你在看这个吗?
Are you looking this?