簡體   English   中英

滾動到WatchKit中的WKInterfaceTable的頂部?

[英]Scroll to top of WKInterfaceTable in WatchKit?

我的情節WKInterfaceTable中有一個WKInterfaceTable 點擊一行后,我對記錄顯示進行了更改,但想滾動到頂部。 我該怎么做呢?

到目前為止,這是我的代碼:

@IBOutlet var currentTable: WKInterfaceTable!

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

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

除非缺少某些內容,否則在表currentTable的API中找不到任何內容?

我想知道您如何監督文檔中的這個簡單解決方案?

這應該可以解決問題:

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

    table.scrollToRowAtIndex(0)
}

另外,您的插座似乎有問題。 如果使用IB創建它們,它將自動將它們標記為“弱”。

希望這個能對您有所幫助 :)

WKInterfaceTable的文檔中,您將找到一個有用的方法,稱為scrollToRowAtIndex 只需提供第一行的索引。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM