0

试图在我的应用程序内的推文中发布屏幕截图.. 到目前为止,我已经将它保存到库中,但我需要发布它......这里是截图和空的推特帖子......

- (IBAction)savephoto:(id)sender {

// Returns 1024x768 for iPad Retina
CGSize screenDimensions = [[UIScreen mainScreen] applicationFrame].size;

// Create a graphics context with the target size
// (last parameter takes scale into account)
UIGraphicsBeginImageContextWithOptions(screenDimensions, NO, 0);

// Render the view to a new context
CGContextRef context = UIGraphicsGetCurrentContext();
[customview.layer renderInContext:context];

// Save to Camera Roll
CGRect contentRectToCrop = CGRectMake(18, 14, 602, 460);
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();

CGImageRef imageRef = CGImageCreateWithImageInRect([screenshot CGImage], contentRectToCrop);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
UIImageWriteToSavedPhotosAlbum(croppedImage, self, nil, nil);

UIGraphicsEndImageContext();

…………

- (IBAction)tweetphoto:(id)sender {

TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:@"Enter tweet here!"];
[twitter addImage:[UIImage imageNamed:@""]];

...........

无法弄清楚在 imageNamed 中输入什么...

4

2 回答 2

2
[...]
UIImage* croppedImage = [UIImage imageWithCGImage:imageRef];

TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:@"Enter tweet here!"];
[twitter addImage:croppedImage];

UIGraphicsEndImageContext();
于 2012-07-01T09:04:52.750 回答
1

你为什么不使用你已经创建的“裁剪图像”对象..你不需要创建另一个使用

[UIimage imageName:@""];

有帮助吗?

于 2012-07-01T09:00:44.123 回答