I'm developing an application that allow the user to share through Facebook,Twitter and Email.
For this social networks I have created a separated class that contains this code:
-(void)Facebooksharing
{
SLComposeViewController *facebook = [[SLComposeViewController alloc] init];
facebook = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebook setInitialText:@"Hello"];
[facebook setTitle:@"Helle"];
ViewController *MainRoot = [[ViewController alloc] init];
[MainRoot presentViewController:facebook animated:YES completion:nil];
}
Whenever I call this function I'm getting this Error:
Warning: Attempt to present <SLComposeViewController: 0x7ffc5afe70e0> on <ViewController: 0x7ffc5af57a60> whose view is not in the window hierarchy!
Anyone can help me please how I can present this view from another class?