Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet weak var hogeTable: WKInterfaceTable!
var test = ["Item1", "Item2", "Item3", "Item4", "Item5"]
override init(context: AnyObject?) {
// Initialize variables here.
super.init(context: context)
loadTableData()
}
// TableのLabelにテキストを流し込む
private func loadTableData() {
hogeTable.setNumberOfRows(test.count, withRowType: "StringTableRowController")
for (index, val) in enumerate(test) {
let row = hogeTable.rowControllerAtIndex(index) as StringTableRowController
row.interfaceLabel.setText(val)
}
}
// Tableをタップした時の画面遷移処理
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
self.pushControllerWithName("DetailController", context: self.test[rowIndex])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.