在 WatchKit 中滚动到 WKInterfaceTable 的顶部?
Scroll to top of WKInterfaceTable in WatchKit?
我的故事板中有一个 WKInterfaceTable
。当点击一行时,我对记录显示进行了更改,但想滚动到顶部。我该怎么做?
到目前为止我的代码是这样的:
@IBOutlet var currentTable: WKInterfaceTable!
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
// Make changes to records...
// TODO: Scroll to the top???
}
我在 API 中找不到 table currentTable
的任何内容,除非我遗漏了什么?
我想知道您是如何在文档中监督这个简单的解决方案的?!
这应该可以解决问题:
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int)
{
// Make changes to records...
table.scrollToRowAtIndex(0)
}
另外你的插座好像不对。如果您使用 IB 创建它们,它会自动将它们标记为 'weak'.
希望这对您有所帮助:)
在 WKInterfaceTable
的文档中,您会找到一个名为 scrollToRowAtIndex
的有用方法。只需提供第一行的索引。
我的故事板中有一个 WKInterfaceTable
。当点击一行时,我对记录显示进行了更改,但想滚动到顶部。我该怎么做?
到目前为止我的代码是这样的:
@IBOutlet var currentTable: WKInterfaceTable!
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
// Make changes to records...
// TODO: Scroll to the top???
}
我在 API 中找不到 table currentTable
的任何内容,除非我遗漏了什么?
我想知道您是如何在文档中监督这个简单的解决方案的?!
这应该可以解决问题:
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int)
{
// Make changes to records...
table.scrollToRowAtIndex(0)
}
另外你的插座好像不对。如果您使用 IB 创建它们,它会自动将它们标记为 'weak'.
希望这对您有所帮助:)
在 WKInterfaceTable
的文档中,您会找到一个名为 scrollToRowAtIndex
的有用方法。只需提供第一行的索引。