这就是我在 UIButton
上订阅点击操作的方式:
_ = mainView.loginButton.rx.tap.subscribe { _ in
//this is not called at all
}
现在我需要强制执行该操作以检查我的依赖项是否正常工作,但未调用订阅处理程序。
func testRouterDidCallWithError() {
let view = LoginView()
let controller = LoginViewController(view: view)
controller.loadView()
view.loginButton.sendActions(for: .touchUpInside) //here is the point
}
最佳答案
这有效(“ReactiveX/RxSwift”~> 4.0)
someButton.rx.tap
.bind {
debugPrint("button tapped")
}
.disposed(by: disposeBag)
别处
someButton.sendActions(for: .touchUpInside)
关于ios - 如何使用 RxSwift 强制点击 UIButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51652030/