2

我的故事板中有一个WKInterfaceTable。点击一行时,我对记录显示进行了更改,但想滚动到顶部。我该怎么做呢?

这是我的代码到目前为止的样子:

@IBOutlet var currentTable: WKInterfaceTable!

override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
    // Make changes to records...

    // TODO: Scroll to the top???
}

currentTable除非我缺少某些东西,否则我在表格的 API 中找不到任何东西?

4

2 回答 2

3

我想知道您是如何在文档中监督这个简单的解决方案的?!

这应该可以解决问题:

override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) 
{
    // Make changes to records...

    table.scrollToRowAtIndex(0)
}

此外,您的出口似乎是错误的。如果您使用 IB 创建它们,它会自动将它们标记为“弱”。

希望对你有帮助 :)

于 2015-04-26T14:29:52.813 回答
2

在 的文档中WKInterfaceTable,您会找到一个有用的方法,称为scrollToRowAtIndex. 只需提供第一行的索引。

https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceTable_class/#//apple_ref/occ/instm/WKInterfaceTable/scrollToRowAtIndex

于 2015-04-26T14:30:06.807 回答