Apple Watch表-前四行未出现 [英] Apple Watch Table - first 4 rows not appearing

查看:112
本文介绍了Apple Watch表-前四行未出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在向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.

我仔细阅读了WKInterfaceControllerWKInterfaceTable的文档,他们建议您应该能够在initawakeWithContext中执行初始化,所以我相信这是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表-前四行未出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆