4

iOS6 の Facebook 機能を使用して、アプリケーションから Facebook にスクリーン ショットをエクスポートしようとしています。ボタンが押されたときにアプリケーション内のオプションを表示するにはどうすればよいですか?

以下は私の現在のコードです。スクリーンショットを撮り、同時に 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);
4

3 に答える 3

2

Apple Developer Site は、Twitter や Facebook などのソーシャル エクスペリエンスを統合するための新しい Social.framework を提供します。

こちらを参照してください。

于 2012-11-07T11:33:20.837 に答える
2

ここでは、iOS6 に組み込まれている Facebook SDK を使用して、簡単に Facebook に画像を投稿する方法を説明します。これが何らかの形でお役に立てば幸いです。ハッピーコーディング:)

于 2012-10-31T10:41:22.313 に答える
1

@ClarenceiOS用の最新のFacebookSDKをチェックする必要があると思います

また、iOS6でFacebookに画像を投稿する方法に関するチュートリアルもいくつかあります。

SDKをダウンロードするだけで、iOS6のFacebookに画像を投稿する方法を示すサンプルHelloFacebookSampleを含むサンプルコードがDocumentsフォルダーにあります。

このメソッドで画像オブジェクトを渡す必要があります-

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

上記の方法を使用する前に、ここでv3.1のインストール手順に正しく従う必要があります

于 2012-10-29T17:01:57.323 に答える