我正在尝试使用以下代码从手表模拟器启动我的 iPhone 应用程序:
WKInterfaceController 子类
[WKInterfaceController openParentApplication:[NSDictionary dictionaryWithObject:@"red" forKey:@"color"] reply:^(NSDictionary *replyInfo, NSError *error) {
NSLog(@"replyInfo %@",replyInfo);
NSLog(@"Error: %@",error);
}];
AppDelegate.m
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
{
NSLog(@"appdelegate handleWatchKitExtensionRequest");
NSLog(@"NSDictionary: %@",userInfo);
NSLog(@"replyInfo: %@",replyInfo);
}
我得到的错误是:
错误:错误域=com.apple.watchkit.errors 代码=2“iPhone 应用程序中的 UIApplicationDelegate 从未在 -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:] 中调用回复()”UserInfo=0x7f8603227730 {NSLocalizedDescription=iPhone 中的 UIApplicationDelegate应用程序从未在 -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]} 中调用 reply()