WatchKit 应用作为 iOS 设备的控制器

WatchKit App as Controller for iOS Device

是否可以让 WatchKit 应用成为其父 iOS 应用的控制器?

我想在 WatchKit 应用程序上设置按钮,以在 iPhone 应用程序上执行操作,但我找不到实现该操作的方法。尝试发送通知 - 不开心。

尝试使用 WKInterfaceController.openParentApplication,但这也不起作用。

有人能指出我正确的方向吗?

谢谢。

请参阅@NatashaTheRobot 博客中的示例:

http://natashatherobot.com/watchkit-open-ios-app-from-watch/

这是我的 handleWatchKitExtensionRequest 的样子。检查代码中此方法的拼写。您在评论中没有拼写正确,这会导致无法识别的选择器崩溃。

-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
    NSString* command = [userInfo objectForKey:@"command"];
    NSString* uuid = [userInfo objectForKey:@"uuid"];

    if (command == nil)
    {
        reply(nil);
    }
    else
    {
        if ([command isEqualToString:@"startTrip"])
        {
            ...
            //The uuid of the trip is returned to the watch app
            reply(@{@"uuid": uuid});
        }
        else if ([command isEqualToString:@"stopTrip"])
        {
            ...                
            reply(nil);
        }
        else if ([command isEqualToString:@"pauseTrip"])
        {
            ...
            reply(nil);
        }
        else if ([command isEqualToString:@"resumeTrip"])
        {
            ...                
            reply(nil);
        }
    }
}