swift - didSelectRowAt Index 卡住 Apple Watch 应用程序

标签 swift tableview watchkit apple-watch didselectrowatindexpath

在我的 WatchKit 应用程序中,我有一个 TableView ,我试图通过按表中的两行不同的行(最后一行和前面一行)来执行两种不同的方法。

下面的代码运行method1,但从未执行method2,即使tableView.numberOfRows 是正确的。该应用程序没有执行方法 2,而是无休止地加载并卡住。

代码可能有什么问题?

override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
    if table==tableView && rowIndex==tableView.numberOfRows-2 {
        print("Its up")
        print(tableView.numberOfRows)
        method1()
    } else if table==tableView && rowIndex==tableView.numberOfRows-1 {
        print("It's down")
        print(tableView.numberOfRows)
        method2()
    } else {
        print("Nothing is happening")
    }
}

最佳答案

if table=tableView && rowIndex==tableView.numberOfRows-2 {

也许第一个相等应该是==

关于swift - didSelectRowAt Index 卡住 Apple Watch 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36249114/

相关文章:

ios - CNContact 显示名称 objective-c /swift

ios - objective-c 传递数据

ios - 如何在 ios 中向我的 ImageView 添加角标(Badge)?

tableview - JavaFX 8 : How to avoid clipped off the text in TableView's column header?

unit-testing - 单元测试 watch 套件扩展

ios - .xcdatamodeld 文件未在 Xcode 中显示数据模型结构

javascript - 在加载外部网站的 UIWebView 上运行 Javascript

ios - 加载的 Nib 不更新框架大小

ios - watchOS 2 上的钥匙串(keychain)访问不适用于实际 watch

ios - Swift JSONSerialization 作为 NSDictionary 无法获取内部的值