I am developing an iPad app that has a large number of UIViewControllers
, UITableViews
(with cells with accessoryViews
of UIText
I actually really like Omar's technique - it works beautifully - but I've added a couple of lines in my case.
- (void)keyboardDidShow:(NSNotification*)notification
{
UIButton *button = [[UIButton alloc] init];
CGRect rect = self.view.bounds;
button.frame = rect;
button.backgroundColor = [UIColor blackColor];
[button setAlpha:0.5f];
button.tag = 111;
UIView *currentResponder = [self.view findFirstResponder];
[self.view bringSubviewToFront:currentResponder];
if (currentResponder == _descriptionTextView) [_descriptionTextView setTextColor:[UIColor whiteColor]];
[button addTarget:currentResponder action:@selector(resignFirstResponder) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:button belowSubview:currentResponder];
}
I've added three lines to his solution (see above):
Anyway, only minor changes, but hopefully these help. Thanks Omar.