如何在facebook集成的文本中发布带有Iphone sdk的图像 [英] How to post images with text in facebook integration in Iphone sdk
问题描述
任何人的帮助将不胜感激。
我假设您想在图片中绘制一些文字,然后将图像上传到Facebook。
首先,我们需要将原始图像和所需文本绘制到新图像中。
UIGraphicsBeginImageContext(CGSizeMake(320.0,320.0));
CGContextRef context = UIGraphicsGetCurrentContext();
//绘制原始图像
[image drawInRect:CGRectMake(0,0,320.0,320.0)];
//绘制文本
[@textdrawInRect:CGRectMake(...)withFont:[UIFont systemFontOfSize:20.0];
UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
然后,将图像转换为NSData,并调用Facebook的photos.uploadAPI上传它。
NSMutableDictionary * args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:@captionforKey:@caption];
FBRequest * uploadPhotoRequest = [FBRequest requestWithDelegate:self];
NSData * data = UIImagePNGRepresentation(newImage);
[uploadPhotoRequest call:@photos.uploadparams:args dataParam:data];
Here Iam having a problem.Actually I implemented the facebook integration in my application and I need to post the images with text but I dont have any idea how to work on this.can anyone suggest this with a sample code so that it is very helpful for me.
Anyone's help will be much appreciated.
I assume that you want to draw some text in an image, and then upload the image to Facebook.
At first, we need to draw the original image and the desired text into a new image.
UIGraphicsBeginImageContext(CGSizeMake(320.0, 320.0));
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw the original image
[image drawInRect:CGRectMake(0, 0, 320.0, 320.0)];
// Draw the text
[@"text" drawInRect:CGRectMake(...) withFont:[UIFont systemFontOfSize:20.0];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
And then, convert the image into NSData and call Facebook's "photos.upload" API to upload it.
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:@"caption" forKey:@"caption"];
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
NSData *data = UIImagePNGRepresentation(newImage);
[uploadPhotoRequest call:@"photos.upload" params:args dataParam:data];
这篇关于如何在facebook集成的文本中发布带有Iphone sdk的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!