I am using social framework for sharing purposes.In IBAction of share Button I post a notification.But when i press cancel button of alert of Settings of particular social networking site then alert hides but keyboard and controller dont hide. I am using following code
- (IBAction)shareOnFB:(id)sender
{
[[NSNotificationCenter defaultCenter]postNotificationName:@"hideNotification" object:nil];
SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controllerSLC setInitialText:_dictShare[@"description"]];
[controllerSLC addURL:[NSURL URLWithString:@"http://www.appcoda.com"]];
// [controllerSLC addImage:[UIImage imageNamed:@"test.jpg"]];
[self presentViewController:controllerSLC animated:YES completion:Nil];
}
Thanks in advance.
I solved it myself.You have to set its completion using following code.
Just add following code after presenting controller
[controllerSLC setCompletionHandler:^
(SLComposeViewControllerResult result) {
[[NSNotificationCenter defaultCenter]postNotificationName:@"hideNotification" object:nil];
NSString *output = [[NSString alloc] init];
switch (result) {
case SLComposeViewControllerResultCancelled:
output = @"Post Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Posted successfully";
break;
default:
break;
}
}];