Я занимаюсь разработкой приложения для iOs 5 ( Просмотреть в App Store ) с собственной интеграцией с Twitter, недавно добавленной в iOs 5. Я использую этот код для создания снимка экрана приложения:
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 снимком экрана.Для обмена в Твиттере я использую это:
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 выше.Спасибо !!!