标签:style os io for cti ar 代码 line
//收回键盘1
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[((UIView*)obj) resignFirstResponder];
}];
}
//收回键盘2
- (void)resignKeyBoardInView:(UIView *)view
{
for (UIView *v in view.subviews)
{
if ([v.subviews count] > 0)
{
[self resignKeyBoardInView:v];
}
if ([v isKindOfClass:[UITextView class]] || [v isKindOfClass:[UITextField class]]) {
[v resignFirstResponder];
}
}
}
//收回键盘3--
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UIView* view in self.view.subviews) {
if ([view isKindOfClass:[UITextField class]])
[view resignFirstResponder];
}
}
//收回键盘4---适用scrollview
//前提:view继承UIContorl,连线Touch Down
//Touch Down--Action
- (IBAction)backgroundTap:(id)sender
{
[phoneNumberTextFiled resignFirstResponder];//通知文本失去第一响应者状态 键盘收回
}
iOS 点击空白处收回键盘的几个简单代码,布布扣,bubuko.com
标签:style os io for cti ar 代码 line
原文地址:http://www.cnblogs.com/Ewenblog/p/3884558.html