gpt4 book ai didi

iphone - 集成iOS6 facebook功能

转载 作者:行者123 更新时间:2023-12-03 19:11:40 26 4
gpt4 key购买 nike

我正在尝试使用 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);

最佳答案

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

关于iphone - 集成iOS6 facebook功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11703924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com