handleWatchKitExtensionRequest 限制
handleWatchKitExtensionRequest limitations
您在 handleWatchKitExtensionRequest
中可以做什么有限制吗?我尝试从资源包中返回 UIImage
,但收到 nil
回复。
这个有效:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
reply(@{@"Returning the number 1":@(1)});
}
这失败了:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
UIImage *image = [UIImage imageNamed:@"icon-152x152.png"];
reply(@{@"image":image});
}
您传递的字典必须符合 属性 列表,这意味着您需要在发送之前将 类 不是字符串、数字、字典和数组的内容转换为 NSData . How to convert UIImage to NSData.
您在 handleWatchKitExtensionRequest
中可以做什么有限制吗?我尝试从资源包中返回 UIImage
,但收到 nil
回复。
这个有效:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
reply(@{@"Returning the number 1":@(1)});
}
这失败了:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
UIImage *image = [UIImage imageNamed:@"icon-152x152.png"];
reply(@{@"image":image});
}
您传递的字典必须符合 属性 列表,这意味着您需要在发送之前将 类 不是字符串、数字、字典和数组的内容转换为 NSData . How to convert UIImage to NSData.