I'm presenting a SLComposeViewController for sending a facebook message. Presenting and posting works fine and the completion block is getting called (all logs are there).
The problem is, when the posting is complete, I also want to dismiss the current view controller (which is presented via a modal segue in storyboard).
I cannot get this VC to dismiss via [self dismissViewControllerAnimated:YES completion:nil];
inside the block.
- (void)postToFacebook
{
NSLog(@"Posting to Facebook ...");
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
NSLog(@"Facebook is available ...");
SLComposeViewController *fbSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
// [self endQuiz];
[self dismissViewControllerAnimated:YES completion:nil];
NSLog(@"FB post complete");
}];
[fbSheet setInitialText:[NSString stringWithFormat:@"I just scored a %i on this game", self.totalPoints]];
[self presentViewController:fbSheet animated:YES completion:^{
NSLog(@"Completed showing FB sheet");
}];
} else {
NSLog(@"Facebook not available");
[self endQuiz];
}
}
I've tried variations of block-safe selfs, thinking maybe self was referencing the wrong controller in the block. No luck there, either.