【发布时间】:2016-02-17 23:58:01
【问题描述】:
我一直在尝试根据所选行在 WatchKit 中设置分层表。
我知道这涉及到使用contextForSegueWithIdentifier。
有人可以解释如何将选定的行详细信息提供给目标接口控制器吗?
@IBOutlet var mainTable: WKInterfaceTable!
let mains = ["Full Schedule", "Custom Sched."]
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
loadTableData()
}
private func loadTableData() {
mainTable.setNumberOfRows(mains.count, withRowType: "InterfaceTableRowController")
for (index, mainName) in mains.enumerate() {
let row = mainTable.rowControllerAtIndex(index) as! InterfaceTableRowController
row.interfaceLabel.setText(mainName)
}
}
override func contextForSegueWithIdentifier(segueIdentifier: String, inTable table: WKInterfaceTable, rowIndex: Int) -> AnyObject?
{
let mainName = mains[rowIndex]
return mainName
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
NSLog("%@ will activate", self)
}
好的,这就是我 [作为我的控制器之一] 所在的位置,并假设如果我选择完整的日程安排,它将显示星期四 > 星期五 > 星期六 > 星期日的列表 .... 但如果我选择自定义它会显示名称 > 名称 > 名称 > 名称
【问题讨论】: