菜鸟教程小白 发表于 2022-12-11 19:32:46

ios - Swift 中 UIButton 的两种方式绑定(bind)


                                            <p><p>我是 RXSwift 的新手。我有 UITableViewCell,它有一个按钮。单击表格 View 之外的全选按钮后,我需要更改按钮状态。我正在更改 View 模型值,但 UI 没有更新。按照我绑定(bind)的方式,如何以两种方式绑定(bind)它? </p>

<pre><code>var isSelectedAttendee: Variable&lt;Bool&gt;
cellViewModel?.isSelectedAttendee.asObservable().bind(to: selectButton.rx.isSelected).disposed(by: disposeBag)
</code></pre>

<p>我知道它不是重复的简单按钮绑定(bind),但在我的情况下,按钮位于 UITableViewCell 内。我尝试了不同的解决方案,但没有解决我的问题。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>阅读一下,作者已经回答过了</p>

<p> <a href="https://github.com/ReactiveX/RxSwift/issues/606" rel="noreferrer noopener nofollow">https://github.com/ReactiveX/RxSwift/issues/606</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Swift 中 UIButton 的两种方式绑定(bind),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/48060422/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/48060422/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Swift 中 UIButton 的两种方式绑定(bind)