开发者

How put a UIView above the keyboard

开发者 https://www.devze.com 2023-04-05 23:02 出处:网络
I have a idea to hide some keys in keyboard. I use the exact background of the keyboard and use it 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];

How put a UIView above the keyboard

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消