首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >集成iOS6 facebook功能

集成iOS6 facebook功能
EN

Stack Overflow用户
提问于 2012-07-29 03:17:52
回答 3查看 627关注 0票数 4

我正在尝试使用iOS6 Facebook函数将我的应用程序中的屏幕截图导出到Facebook。当按钮被按下时,我如何调出应用程序中的选项?

下面是我当前的代码。我想采取屏幕截图,同时导出到Facebook使用iOS6 Facebook功能。

代码语言:javascript
复制
- (IBAction)export1:(id)sender{

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath
                      atScrollPosition:UITableViewScrollPositionTop
                              animated:YES];
exporting.hidden=YES;

CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions)
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);

else
    UIGraphicsBeginImageContext(imageSize);

CGContextRef context = UIGraphicsGetCurrentContext();

// Iterate over every window from back to front
for (UIWindow *window in [[UIApplication sharedApplication] windows]) 
{
    if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen])
    {
        // -renderInContext: renders in the coordinate space of the layer,
        // so we must first apply the layer's geometry to the graphics context
        CGContextSaveGState(context);
        // Center the context around the window's anchor point
        CGContextTranslateCTM(context, [window center].x, [window center].y);
        // Apply the window's transform about the anchor point
        CGContextConcatCTM(context, [window transform]);
        // Offset by the portion of the bounds left of and above the anchor point
        CGContextTranslateCTM(context,
                              -[window bounds].size.width * [[window layer] anchorPoint].x,
                              -[window bounds].size.height * [[window layer] anchorPoint].y);

        // Render the layer hierarchy to the current context
        [[window layer] renderInContext:context];

        // Restore the context
        CGContextRestoreGState(context);
    }
}

// Retrieve the screenshot image
CGRect contentRectToCrop = CGRectMake(0, 70, 740, 740);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], contentRectToCrop);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(croppedImage, nil, nil, nil);
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-10-31 18:41:22

Here是如何使用iOS6中内置的Facebook SDK轻松地将图片发布到Facebook。如果这对你有任何帮助,我很高兴。快乐编码:)

票数 2
EN

Stack Overflow用户

发布于 2012-11-07 19:33:21

苹果开发者网站提供了一个新的Social.framework,用于集成推特和脸书等社交体验。

请参阅here

票数 2
EN

Stack Overflow用户

发布于 2012-10-30 01:01:57

@Clarence我认为你应该看看最新的Facebook SDK for iOS

它还提供了一些在iOS 6中如何在facebook上发布图片的教程。

只需下载开发工具包,你就会在你的Documents文件夹中找到示例代码,其中包括一个示例HelloFacebookSample,它展示了如何在iOS 6中将图片发布到facebook上。

你只需要在这个方法中传递你的图像对象-

代码语言:javascript
复制
[FBNativeDialogs presentShareDialogModallyFrom:self initialText:nil image:croppedImage url:nil handler:nil];

在使用上述方法之前,您需要正确遵循v3.1安装说明here

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

https://stackoverflow.com/questions/11703924

复制
相关文章

相似问题

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