菜鸟教程小白 发表于 2022-12-11 18:15:30

iOS indexPathsForSelectedRows 和初始选择


                                            <p><p> <a href="/image/ywYL5.png" rel="noreferrer noopener nofollow"><img src="/image/ywYL5.png" alt="When I enter editing mode"/></a> <a href="/image/SuP07.png" rel="noreferrer noopener nofollow"><img src="/image/SuP07.png" alt="Before entering editing mode"/></a> </p>

<p>我有一个 UITableView,它显示产品的功能,并在单元格右侧显示支持功能的复选标记。该应用程序允许用户检查更多功能或取消选中其他功能,并让 UITableView 进入编辑模式并启用多选模式。问题是我想设置已经选中的功能(为了让用户取消选中它们),但是 indexPathsForSelectedRows 是只读的,我找不到初始化某些行的方法,因此当网格进入时它们已经被选中编辑模式。有没有办法得到这个结果?任何帮助将不胜感激。</p>

<p>图片显示了这两种情况。当表格 View 不处于编辑模式时,我有复选标记附件。当表格 View 进入编辑模式并启用多选时,它会显示复选框......但它们都未选中,我无法以编程方式检查它们......或者至少看起来是这样的</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果勾号是选择样式,可以尝试使用</p>
<p><code>uitableView.deselect Row(at: indexPath, animated: true)</code></p>
<p>在<code>didSelectRowAtIndexPath</code>方法中</p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS indexPathsForSelectedRows 和初始选择,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/40949194/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/40949194/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS indexPathsForSelectedRows 和初始选择