首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >处理UIActivityViewController

处理UIActivityViewController
EN

Stack Overflow用户
提问于 2015-09-07 12:29:52
回答 1查看 79关注 0票数 0

首先,我找不到其他有这个问题的人。在spritekit中处理游戏-有一个mainTitle.h/m和gamePlay.h/m文件。下面是分享按钮的代码,它可以通过文本、fb、twitter等分享你的进度。下面的代码位于touch方法中的gamePlay.m中。然而,在用户选择发送他/她的分数视图文本消息后,代码可以工作-新的消息窗口滑出,然后游戏显示重新启动并加载mainTitle.m场景。你知道为什么会发生这种情况吗?

代码语言:javascript
复制
-(void)share {
  UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 1.0);
  [self.view.drawViewHierarchyInRect:self.view.boundsafterScreenUpdates:YES];
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();

  NSString *message = [NSString stringWithFormat:@"messge"];
  NSString *urlString = [NSString stringWithFormat@"www..."];
  NSURL *gmURL = [NSURL URLWithString:urlString];

  UIActivityViewController *actVC = [[UIActivityViewController alloc] 
  initWithActivityItems:@[message, gmURL, image] applicationActivites:nil];
  actVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeAriDrop];

  UIViewController *viewControl = self.view.window.rootViewController;
  [viewControl presentViewController:actVC animated:YES completion:nil];
}

-(void)touchBegins ... {
    [self share];
}
EN

回答 1

Stack Overflow用户

发布于 2015-09-07 15:17:16

在touchBegan中调用share方法可能不是一个好主意,因为在某些情况下它可能会被多次触发。改用如UIButton

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32431109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档