1
我正在開發一個iOS 5的應用程序(View in App Store)與本地Twitter的整合最近在iOS 5.我使用這個代碼以應用程序的屏幕截圖:分享到微博的屏幕捕獲的IOS5
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.view.bounds.size);
// retrieve the current graphics context
CGContextRef context = UIGraphicsGetCurrentContext();
// render view into context
[self.view.layer renderInContext:context];
// create image from context
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// save image to photo album
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(image:didFinishSavingWithError:contextInfo:),
@"image.png");
`
我希望用戶可以在Twitter上自動分享屏幕截圖。對於在Twitter上分享我使用的是:
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:[NSString stringWithFormat:@"Final score %@: %d vs. %@: %d ",intnomlocal, puntsl, intnomvisitant, puntsv]];
//[twitter addImage:[UIImage imageNamed:@"image"]];
//[twitter addURL:[NSURL URLWithString:@"http://www.erwinzwart.com"]];
[self presentViewController:twitter animated:YES completion:nil];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
if(res == TWTweetComposeViewControllerResultDone)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Done!" message:@"Your tweet was send" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}else if(res == TWTweetComposeViewControllerResultCancelled)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Cancelled" message:@"Your tweet wasn't send" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
[self dismissModalViewControllerAnimated:YES];
};
我該如何融合這兩個代碼。我的意思是,當一個按鈕被按下時,使屏幕截圖,保留它並在上面的本地Twitter上分享。謝謝!!!
我剛剛嘗試過,並且收到了千兆位的錯誤。還有什麼...:D – 2012-01-08 11:38:27
但是,我有什麼代碼: 1. [twitter addImage:[UIImage imageNamed:@「image」] 2. [twitter addImage:[UIImage imageNamed:image] 因爲第一個是字符串,第二個是代碼名稱 – 2012-01-08 11:39:29
如此簡單:[twitter addImage:image] – Felix 2012-01-08 11:46:17