Apple Watch 表 - 前 4 行没有出现 [英] Apple Watch Table - first 4 rows not appearing
问题描述
我在 Apple Watch 上向 WKInterfaceTable
添加行时遇到问题.奇怪的是,无论我做什么,前 4 行都显示为空.我尝试手动和循环添加行 - 没关系.我相信我的代码很好,因为第 5 行和更多行看起来很好.这是发生的事情:
I'm having problems adding rows to WKInterfaceTable
on Apple Watch. The weird thing is that no matter what I do, the first 4 rows appear as empty. I tried adding rows manually and in a loop - doesn't matter. I believe my code is good because 5th and further rows appear just fine. Here's what happens:
进一步滚动:
我的代码:
import Foundation
import WatchKit
class TableInterfaceController: WKInterfaceController{
@IBOutlet weak var agentTable: WKInterfaceTable!
let agents = ["The Dude","Walter","Donnie","Maude","Knox","Karl","Nihilist 2"]
override init(){
super.init()
loadTableData()
}
private func loadTableData(){
agentTable.setNumberOfRows(agents.count, withRowType: "AgentTableRowController")
println("Count: \(agents.count)")
for(index,agentName) in enumerate(agents){
let row = agentTable.rowControllerAtIndex(index) as AgentTableRowController
println(agentName, index)
row.agentLabel.setText(agentName)
}
}
}
任何帮助表示赞赏.这可能是一件小事.我在优胜美地 10.10.2 上运行 Xcode 6.2 (6C131e)
Any help appreciated. It's probably something trivial. I'm running Xcode 6.2 (6C131e) on Yosemite 10.10.2
推荐答案
我在 awakeWithContext
中初始化我的表时遇到了完全相同的问题.通过按照 dan 的建议将我的表初始化移动到 willActivate
中,问题得到了解决.
I was having the exact same issue when initializing my table in awakeWithContext
. By moving my table initialization into willActivate
as suggested by dan the issue was solved.
我仔细阅读了 WKInterfaceController
和 WKInterfaceTable
的文档,他们建议你应该能够在 中执行初始化init
或 awakeWithContext
,所以我相信这是 WatchKit 框架中的一个错误.
I sifted through the documentation of both WKInterfaceController
and WKInterfaceTable
and they suggest that you should be able to perform the initialization in init
or awakeWithContext
, so I believe this is a bug in the WatchKit framework.
这篇关于Apple Watch 表 - 前 4 行没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!