我有一个iPhone应用程序,可以在5-10秒后将UIView捕获为UIImage。有没有可能将UIImage传递给我的Apple应用程序并在UIImageView中显示出来呢?
发布于 2015-04-08 13:22:17
是的。您所需要做的就是创建一个NSDictionary,如:
var dict:[NSString : UIImage] = ["image" : yourImage]然后,您只需使用以下方法在Apple和iOS应用程序之间进行通信:链接
发布于 2015-07-08 15:02:35
这里的答案只有一半是正确的,因为你不能直接发送UIImage!你需要像f.e那样以NSData的形式发送你的图像。因此:
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo
reply:(void (^)(NSDictionary *))reply
{
reply(@{@"image" : UIImagePNGRepresentation(yourUIImage)});
// JPEG Representation would of course also work
}发布于 2015-04-08 13:48:59
是的你能做到的。
可以使用此方法传递数据。
- (IBAction)passUserInfo:(id)sender
{
NSDictionary *userInfo = @{@"image":[UIImage imageNamed:@"test"]};
[WKInterfaceController openParentApplication:userInfo reply:^(NSDictionary *replyInfo, NSError *error){
if ([replyInfo objectForKey:@"success"]) {
NSLog(@"Sent your data");
}
}];// userinfo must be non-nil
}你可以用这个方法处理你的数据。
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
{
UIImage *image = [userInfo objectForKey:@"image"];
NSDictionary *replyInfo = @{@"success":@"success",@"error":@""};
reply(replyInfo);
}否则,请参阅本教程
https://stackoverflow.com/questions/29515599
复制相似问题