How to enable user to click the View to hide the kb on iPhone?
I find that the View do not have a touch inside or similar event. So, I make a 开发者_如何学Gobutton on top on the view, and set it Alpha to 0, but after I set to Alpha 0, it cannot touch anymore. Any ideas on this?
You can use UIView
subclass and handle touch event there. Methods to look at (defined in UIResponder
):
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
If you want to use "invisible" UIButton
you should set its type to UIButtonTypeCustom
- by default it will appear with no image and title and with transparent background. So technically it will be invisible to user but still be able to respond to all events.
精彩评论