Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...