I have been trying to make it so that when the the screen of the SLComposeViewController
is tapped (such as when the background is tapped), the keyboard disappears. There are several tutorials on how to do this with a regular UIViewController
and textfields, however I cannot seem to make it work for the SLViewController
. Here is the basic idea:
I have a SocialViewController
class which is derived from the SLComposeViewController
class, and when the correct button is pressed on the screen, I do this:
SocialViewController *socialViewController = [[SocialViewController alloc] initFacebookViewController];
if ( !(socialViewController == nil) )
{
[self.view.window.rootViewController presentViewController:socialViewController.fbController
animated:YES
completion:nil];
}
Here is what my initFacebookController does:
@interface SocialViewController ()
@end
@implementation SocialViewController
@synthesize fbController;
-(id) initFacebookViewController {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
fbController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
// I have been trying to make this part work
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:fbController
action:@selector(clickBackground:)];
[fbController.view addGestureRecognizer:tap];
return self;
}
else
{
UIAlertView *notLoggedIn = [[UIAlertView alloc]
initWithTitle:@"Not Signed In"
message:@"Please login."
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil, nil];
[notLoggedIn show];
return nil;
}
}
And finally, I would like to resign the keyboard when I tap the screen (using the clickedBackground selector), however, I've just been trying to get it to print to the log:
- (void)clickBackground:(UITapGestureRecognizer *)tap {
//resign the keyboard here, and lately been trying to print to the log.
//[fbController resignFirstResponder];
}
This wouldn't be such a problem, but my app is suppose to be used in landscape orientation. And the iPhone 4 and 5's keyboard don't have the "stop displaying keyboard" button like the iPhone 6's keyboard does, and it's hard to see the compose window. I have tried multiple other methods with no avail, and if anyone has some insight about how I might make the keyboard disappear in the SLComposeViewController
when the screen is tapped I'd be grateful.
Also, one further note I noticed. It seems that when the SLComposeViewController
is presented, the view for the controller is presented, and then another view, the "compose window" is put on top of the controller view, hence why my tap gestures do not work (because the "compose window" view is on top of the view I assigned the tap gesture to).
Any insight is appreciated, and if more information is needed, I'd be happy to provide it. Thanks.