How put a UIView above the keyboard
I have a idea to hide some keys in keyboard. I use the exact background of the keyboard and use it above the keyboard.
So I create a textView and add a accessoryView
//Create the view
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -10, 768, 300)];
[view setBackgroundColor:[UIColor greenColor]]
UIText开发者_运维百科Field text = [[UITextField alloc] initWithFrame:CGRectMake(120, 10, 80, 28)];
[text setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
[text setInputAccessoryView:view];
This really hide the keyboard, but if I click in this view, the button still show. I try to use a UIButton, but the button don't catch the click. And I try becameFirstResponder
when UIKeyboardDidShowNotification
and no success.
Any Ideas?
You can set userInteractionEnabled
to YES for your accessory view. This will make your view swallow all the touches.
If you want a custom view for editing, though, you can do this by setting a specific editing view for your field rather than trying to put something else on top of the keyboard.
精彩评论