我已经为Facebook和Twitter按钮整合了以下代码。
我目前在社交媒体表中有测试图片发布 - 但是我想发布当前的应用程序屏幕而不是预先确定的图像,因为屏幕一直在变化。
我该怎么办?
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Test Run!"];
if (![tweetSheet addImage:[UIImage imageNamed:@"test1.jpg"]]) {
NSLog(@"Unable to add the image!");
}
if (![tweetSheet addURL:[NSURL URLWithString:@"http://twitter.com/"]]){
NSLog(@"Unable to add the URL!");
}
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"Test Run"];
[controller addURL:[NSURL URLWithString:@""]];
[controller addImage:[UIImage imageNamed:@"test2.jpg"]];
[self presentViewController:controller animated:YES completion:Nil];
}