0

在我的 iPad 应用程序中,我正在加载 HTML5 页面,我想将这些页面分享到 Facebook。是否可以?我搜索了很多,但找不到任何帮助。我的应用应该支持 iOS5 或更高版本。任何帮助将不胜感激。

我在下面使用来分享图像。

    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
    [variables setObject:graph_file forKey:@"file"];
    [variables setObject:@" image : Shared Via IOS application" forKey:@"message"];
    FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"117795728310/photos" withPostVars:variables];
4

1 回答 1

0

我有同样的问题,solutionrender HTML5 pagesUIWebView它加载capture image的时候,然后是share.

+(UIImage *)imageFromWebView:(UIWebView *)view
{
  // tempframe to reset view size after image was created
  CGRect tmpFrame         = view.frame;

  // set new Frame
  CGRect aFrame               = view.frame;
  aFrame.size.height  = [view sizeThatFits:[[UIScreen mainScreen] bounds].size].height;
  view.frame              = aFrame;

  // do image magic
  UIGraphicsBeginImageContext([view sizeThatFits:[[UIScreen mainScreen] bounds].size]);

  CGContextRef resizedContext = UIGraphicsGetCurrentContext();
  [view.layer renderInContext:resizedContext];
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  // reset Frame of view to origin
  view.frame = tmpFrame;
  return image;
}
于 2013-01-10T06:02:18.360 回答