Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

objective c - How to run a WatchKit App

I can't run a watchkit app from a new project. If I run Apple's sample project it runs fine. If I add watchkit to my existing project by adding a target for watchkit. Then run it I get a black screen with the time even though in my storyboard I have an interface controller that is set to main that has a blue background. This line of code gets called.

- (void)willActivate {
    // This method is called when watch view controller is about to be visible to user
            [self.listTable setNumberOfRows:5 withRowType:@"List"];
    NSLog(@"%@ will activate", self);
}

My main app(iPhone app) for iPhone doesn't get run on the simulator.

This is basically what I see.

Apple Watch Simulator black screen with time label in upper right corner

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you run, did you change the scheme to the WatchKit App target? Or did you just build & run the iOS app as usual? For now you can't run both the iOS app target and Watch App target at the same time.

You have to switch schemes/targets as shown here, then pick the same simulator & display the watch UI as you've already done, (in the simulator -> "Hardware" tab -> External Display -> Apple Watch):

XCode screenshot of scheme dropdown

You also have to add/edit schemes to view the Glance or Notification parts of the storyboard. See the "Readme" file in the sample Lister project for more details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...