I have the following code to post to Facebook for my app;
This is the .h file
#import <UIKit/UIKit.h>
#import <Social/Social.h>
#import <Accounts/Accounts.h>
@interface LifeTipsViewController : UIViewController {
SLComposeViewController *mySLComposerSheet;
}
-(IBAction)PostToFacebook:(id)sender;
@end
and the .m file (Facebook posting code)
-(IBAction)PostToFacebook:(id)sender {
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:@"hi"];
[self presentViewController:mySLComposerSheet animated:YES completion:NULL];
}
I want to be able to press the 'Share' button and the app to get a screen shot of the current view to post to Facebook. What code would need to be added to this Facebook posting code to allow it to share a screen shot of the app? Is this even possible?
Thanks in advance.
Something like this.
-(IBAction)PostToFacebook:(id)sender {
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:@"hi"];
UIGraphicsBeginImageContext(self.window.bounds.size);
[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
[mySLComposerSheet addImage:image];
[self presentViewController:mySLComposerSheet animated:YES completion:NULL];
}