Created
January 17, 2015 12:55
-
-
Save syossan27/986c4d193494cb6a0fa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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