Updating some code for iOS 8. I came across this error in the iPad application, which worked flawlessly in iOS 7. I use UIActionSheet to present options for sharing options, Facebook and Twitter give me a damn thing.
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. But on iOS 8, I get lower
Warning: attempt to present SLComposeViewController: 0x1a238760> on PostDetailViewController: 0x180c5200>, which already represents (Zero)
I saw this error below, and I realized what it was all about. However, his statement by my PostDetailViewController already represents (null)?!? So basically itβs already occupied with nothing?
I tried to present the SLComposeViewController from another VC to the heart, but I keep getting Attempt to present error . I tried to submit from
UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController , and self.navigationController no avail. I also tried pushing the SLComposeViewController from self.navigationController, which actually works, but gives unwanted results as it pushes an empty background and stays there until the SLComposeViewController is closed and the user returns.
Any conclusions would be wonderful! 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]; } }