use*_*278 0 objective-c nsnotifications nsnotificationcenter ios watchkit
我想在手表中创建一个按钮,同时点击手表启动一个进程到我的ios应用程序.如何在两台设备之间发送数据
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(sayHello:) name: @"sayHelloNotification" object: nil];
}
Run Code Online (Sandbox Code Playgroud)
加
[[NSNotificationCenter defaultCenter] postNotificationName: @"sayHelloNotification" object: nil];
Run Code Online (Sandbox Code Playgroud)
在我的按钮手表,但它不起作用
Wes*_*ton 10
如果要将数据发送到父应用,请使用.
[WKInterfaceController openParentApplication:userInfo reply:^(NSDictionary *replyInfo, NSError *error){}];
Run Code Online (Sandbox Code Playgroud)
在您的监视应用程序中调用此方法将触发AppDelegate中的回调
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply;
Run Code Online (Sandbox Code Playgroud)
您必须在发送的userInfo字典中定义数据.
| 归档时间: |
|
| 查看次数: |
10177 次 |
| 最近记录: |