在詢問之前,我已經閱讀了幾個問題/答案,並且還附加了過程,但似乎不起作用。父handleLatchKitExtensionRequest從未被調用?
我的watchkit擴展是用Swift編寫的,而AppDelegate是Objective-C(因爲它是舊代碼)。
在我的分機,我叫:
@IBAction func toPage2() {
println("to page 2")
WKInterfaceController.openParentApplication(["page":"2"], reply: {(reply, error) -> Void in })
}
在我的AppDelegate,我試着打印
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
{
NSLog(@"handle watchkit");
NSString *file = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"page2"] ofType:@"wav"];
AVAudioPlayer *audio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:file] error:nil];
[audio play];
...
我也嘗試調試>附加到進程,然後選擇iPhone應用程序,並且仍然一無所獲發生了。任何人都可以指出我的方向嗎?
是否也發生在當主的iPhone應用程序是活動的模擬器這個問題?也許這有助於:http://stackoverflow.com/questions/30000274/calling-parent-application-from-watch-app – vomako