简体   繁体   中英

Apple Watch Table Controller Not Loading

I'm just working on a simple table app using WatchKit

I think I have everything all set up, and after lots of digging still can't figure out why my app isn't loading.

When I build the app not of my extension's code is being run (breakpoints aren't activating even at the awakeWithContext func.

It just shows a spinning wheel and doesn't load anything in the app, including other elements that load when I disable the code for the interaction table..

Here is my code:

class VisitorInteractionTable: WKInterfaceController {

    @IBOutlet weak var visitorTable: WKInterfaceTable!

    let names = ["Friend1", "Friend2", "Friend3", "Friend4", "Friend5"]


    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context)


        loadTableData()
    }

    private func loadTableData(){
        visitorTable.setNumberOfRows(names.count, withRowType: "VisitorTableRowController")

        for (index, friendName) in enumerate(names) {
            let row = visitorTable.rowControllerAtIndex(index) as VisitorTableRow
            row.rowLabel.setText(friendName)
        }
    }

    override func willActivate() {
        // This method is called when watch view controller is about to be visible to user
        super.willActivate()
        NSLog("%@ will activate", self)
    }

    override func didDeactivate() {
        // This method is called when watch view controller is no longer visible
        NSLog("%@ did deactivate", self)
        super.didDeactivate()
    }
}

I've checked all my storyboard and everything is connected the way it should be, I'm not sure whats going on. Any ideas?

In order to run an Apple Watch app, it needs a parent iPhone app, which will install an accompanying WatchKit Extension for your app. Before your can run your Watch app, you need to build and run your iPhone app as the primary target at least once. Symptomatically, it would appear that this completes the installation process in some fashion, as after this, your Watch app will run successfully. This is one possible explanation for the symptoms you are describing.

Note this may simply be that this is a symptom of the way the Watch is simulated. Apple have not given any indication of what the user experience will be for installing Watch apps, so we can't conclude that it is essential that a new app is run on an actual phone before the accompanying Extension-supported Watch app is run on an actual Apple Watch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM