简体   繁体   English

集成iOS6 Facebook功能

[英]Integrating iOS6 facebook function

I am trying to export a screen shot from my application to Facebook using the iOS6 Facebook function. 我正在尝试使用iOS6 Facebook功能将应用程序的屏幕截图导出到Facebook。 How can I bring out the options inside the application when the button is pressed? 按下按钮后,如何在应用程序内部显示选项?

Below is my current code. 下面是我当前的代码。 I want to take the screenshot and at the same time export to Facebook using iOS6 Facebook function. 我想截取屏幕截图,同时使用iOS6 Facebook功能将其导出到Facebook。

- (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);

Here is how to post images to Facebook easily using the built in Facebook SDK in iOS6. 是使用iOS6中内置的Facebook SDK轻松将图像发布到Facebook的方法。 Happy if this helps you in any ways. 很高兴这对您有任何帮助。 Happy coding :) 快乐的编码:)

The Apple Developer Site Gives a new Social.framework for integrating the Social Experiences like Twitter and Facebook. 苹果开发者网站为整合Twitter和Facebook之类的社交体验提供了新的Social.framework。

Refer here . 请参考这里

@Clarence i think you should check out latest Facebook SDK for iOS @Clarence我认为您应该查看适用于iOS的最新Facebook SDK

it also has some tutorials on how to post images on facebook in iOS 6. 它还提供了一些有关如何在iOS 6中在Facebook上发布图像的教程。

Just download the SDK and you will find sample codes in your Documents folder which include a sample HelloFacebookSample which shows how to post image on facebook in iOS 6. 只需下载SDK,您就会在Documents文件夹中找到示例代码,其中包括示例HelloFacebookSample,该示例显示了如何在iOS 6中的Facebook上发布图像。

you just need to pass your image object in this method - 您只需要通过此方法传递图像对象-

[FBNativeDialogs presentShareDialogModallyFrom:self initialText:nil image:croppedImage url:nil handler:nil];

before using above method you need to properly follow v 3.1 installation instructions here 使用上面的方法之前,你需要正确地遵循v 3.1的安装说明在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM