菜鸟教程小白 发表于 2022-12-11 17:26:50

ios - WKInterfaceTable 不可选择


                                            <p><p>我正在使用 Xode 8 beta 6 为 <code>watchOS 3</code> 创建一个应用程序。
使用自定义行创建 <code>WKInterfaceTable</code> 时,我似乎无法使选择正常工作。</p>

<p>我确实<strong>不</strong>想要执行转场,我只是想获得 <code>didSelectRowAtrowIndex</code>
调用。</p>

<p>设置:</p>

<ul>
<li>我的行有一个标识符</li>
<li>“可选”复选标记已设置</li>
<li>我的行的自定义类已设置</li>
<li>WKInterfaceTable 有一个 IBOutlet</li>
<li>didSelectRowAt 已实现但从未被调用</li>
</ul>

<p>以下函数没有被调用:</p>

<pre><code>override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int)
{print(&#34;selected \(rowIndex)&#34;)}
</code></pre>

<p>我的行没有 segue 集,这似乎是其他人遇到的问题。
该表是我使用 push segue 打开的 View 的一部分</p>

<p><strong>rootViewController -push-> myViewWithTableController -touchCell-> 没有任何反应</strong></p>

<p>我错过了什么? </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我在文档中搜索了转换的任何限制条件,但找不到。
<a href="https://developer.apple.com/documentation/watchkit/storyboard_elements/building_watchos_app_interfaces_using_the_storyboard/navigating_between_scenes" rel="noreferrer noopener nofollow">https://developer.apple.com/documentation/watchkit/storyboard_elements/building_watchos_app_interfaces_using_the_storyboard/navigating_between_scenes</a> </p>

<p>尝试了一些模式。</p>

<ul>
<li>rootController -nextPage -> tableController -push (touchCell) -> NG</li>
<li>rootController -push -> tableController -push (touchCell) -> OK</li>
<li>rootController -modal -> tableController -push (touchCell) -> NG</li>
<li>rootTableController -push (touchCell) -> 确定</li>
</ul>

<p>如果将tableController的<code>Action Segue</code>从<code>Push</code>改为<code>Modal</code>,就可以过渡了。</p>

<p>另外,<code>didSelectRowAt</code> 在 Storyboard 中加入 segue 时不会被调用。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - WKInterfaceTable 不可选择,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/39331481/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/39331481/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - WKInterfaceTable 不可选择