gpt4 book ai didi

ios - 从另一个 View Controller 退出 First Responder

转载 作者:行者123 更新时间:2023-11-29 10:56:47 24 4
gpt4 key购买 nike

我有一个奇怪的案例,我正在使用来自 John Lluch 的很棒的 SWRevealViewController有 2 个侧面导航 Controller (如 Facebook 应用程序),当 UIBarButtonItem 被触摸时,它们会向左和向右滑出。

但是 - 我需要前 View Controller 来确保在这些操作发生时退出第一响应者,但这些栏按钮的关联操作发生在另一个 View Controller 类中。

我需要:

  1. 将另一个操作与我可以在需要退出第一响应者的 View 中调用的 UIBarButtonItem 相关联,或者
  2. 在 ViewDidAppear 上或在 SWRevealController 类中为主视图放弃第一响应者

你能为另一个 View Controller 的一个 View 辞去第一响应者吗?

最佳答案

you can do it using NSNotificationCenter as below.

//.m file:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(LoadTableBasedOnCorner:) name:@"LoadTable" object:nil];

in which class you use above addObserver, you have to implement that method.

//.m file from where you want to send action, call method as below.

[[NSNotificationCenter defaultCenter] postNotificationName:@"LoadTable" object:nil];

关于ios - 从另一个 View Controller 退出 First Responder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17913406/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com