要运行示例项目,请克隆 repo,然后首先从 Example 目录运行 pod install
。
IQTextInputViewNotification 可以通过 CocoaPods 获得。 要安装它,只需将以下行添加到您的 Podfile
pod 'IQTextInputViewNotification'
要观察 textInputView becomeFirstResponder 和 resignFirstResponder 的变化,请订阅 textInputView 事件:-
import IQTextInputViewNotification
class ViewController: UIViewController {
private let textInputViewObserver: IQTextInputViewNotification = .init()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Subscribe
textInputViewObserver.subscribe(identifier: "YOUR_UNIQUE_IDENTIFIER") {info in
print(info.event.name) // BeginEditing or EndEditing event
print(info.textInputView) // TextInputView which begin editing or end editing
// Write your own logic here based on event
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Unsubscribe
textInputViewObserver.unsubscribe(identifier: "YOUR_UNIQUE_IDENTIFIER")
}
}
Iftekhar Qurashi hack.iftekhar@gmail.com
IQTextInputViewNotification 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。