我正在尝试创建一个包含不同行数的节的表。我看到这里给出的解决方案How to create sections in WKInterfaceTable并尝试如下:
tableView.setRowTypes(rowTypes);
for q in 0...rowTypes.count-1 {
if (rowTypes[q] == "teamSection") {
let row = tableView.rowControllerAtIndex(q) as? teamSection;
}
else {
let row = tableView.rowControllerAtIndex(q) as? teamRow;
}
}
我的
rowTypes
如下:let rowTypes = ["teamSection", "teamRow", "teamSection", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow"];
我本来期望11行,但现在只得到9行,它们都是
teamRow
类型,而不是teamSection
类型。有人能发现哪里做错了吗?
最佳答案
似乎teamSection
不是有效的行类型。您确定已经在脚本中设置了包含两行的表,并将其中一行的标识符正确设置为“teamSection”了吗?