私はテーブルを使って簡単なWatchKitアプリケーションを構築しようとしています。各行にはラベルがあります。ここに私のTableRowControllerクラスです:私のInterfaceControllerでWKInterfaceTableが行を作成しない
import WatchKit
class TaskTableRowController: NSObject {
@IBOutlet var taskName: WKInterfaceLabel!
}
、私は私のテーブルに行を追加し、ラベルのテキストを設定してみてください。しかし、taskList.rowController(at:0)は行を見つけられないので、Labelは変更されません。ここで
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var taskList: WKInterfaceTable!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
taskList.setNumberOfRows(1, withRowType: "TaskRow")
if let x = taskList.rowController(at: 0) as? TaskTableRowController
{
x.taskName.setText("Hello World")
}
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
}
は、Interface Builderの出力からいくつかの画面です:
このチュートリアルをご覧くださいhttps://www.appcoda.com/selectable-table-watchkit/ – Dmitry
@csstudent下記の回答を確認してください... –
あなたは以下のコードをチェックしていますか? –