Updating some code for iOS 8. I ran into this error on an iPad only app which worked flawlessly in iOS 7. I'm using a UIActionSheet to present options of share options, Facebook and Twitter are giving me heck.
SLComposeViewController *facebookShare = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
//I add an image if there is one
//I set some initial text
[self presentViewController:facebookShare animated:YES completion:nil];
Pretty straight forward stuff. But on iOS 8 I get the below
Warning: Attempt to present SLComposeViewController: 0x1a238760> on PostDetailViewController: 0x180c5200> which is already presenting (null)
I've seen this error below and I get what its all about. However its saying my PostDetailViewController is already presenting (null)?!? So basically its already busy with nothing?
I've attempted to present the SLComposeViewController from other VC's in the hearty but I keep getting the Attempt to present error
. I've tried presenting from
UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController , and self.navigationController
to no avail. I've also tried pushing the SLComposeViewController from self.navigationController which actually works but gives undesired results as it pushes an empty background then stays there until SLComposeViewController is closed and the user presses back.
Any leads would be great! Thanks in advance.
EDIT 1:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0)[self shareWithTwitter];
if (buttonIndex == 1)[self shareWithFacebook];
if (buttonIndex == 2)[self shareWithiMessage];
if (buttonIndex == 3)[self shareWithEmail];
if (buttonIndex == 4)[self SaveImageToCameraRoll];
}
-(void)shareWithFacebook{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
//add animal URL
SLComposeViewController *facebookShare = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookShare addURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.somelink.com/detail.aspx?id=%@",theAnimal.AnimalID]]];
//add image if there is one
if (theAnimal.PhotoUrl) {
[facebookShare addImage:imageView1.image];
}
//set initial text
if ([theAnimal.Sex isEqualToString:@"Male"]) {
[facebookShare setInitialText:[NSString stringWithFormat:NSLocalizedString(@"pop_his_fb_share", nil),theAnimal.Name]];
}else [facebookShare setInitialText:[NSString stringWithFormat:NSLocalizedString(@"pop_her_fb_share", nil),theAnimal.Name]];
[self presentViewController:facebookShare animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"alert", nil)] message:[NSString stringWithFormat:NSLocalizedString(@"details_no_fb_account", nil)] delegate:nil cancelButtonTitle:[NSString stringWithFormat:NSLocalizedString(@"dismiss", nil)] otherButtonTitles:nil, nil];
[alert show];
}
}