TextFiled 自定义视图, 点击回收键盘;

// 设置return 的样式

textFiled.returnKeyType = UIReturnKeyGo;

// 设置 自定义 弹出视图(自定义键盘)

UIView *inputView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 200)];

inputView.backgroundColor = [UIColor cyanColor]; textFiled.inputView = inputView;

// 设置键盘 上的辅助视图

    UIView *inputAccView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];

    inputAccView.backgroundColor = [UIColor cyanColor];

    //textFiled.keyboardType = UIKeyboardTypeNumberPad;

    textFiled.inputAccessoryView = inputAccView;

    [inputAccView release];

#pragma mark --- UITextFailed

 

// 当点击键盘上的 return , 触发该方法

-(BOOL)textFieldShouldReturn:(UITextField *)textField {

    //点击 return 回收键盘

    [textField resignFirstResponder];

    return YES;

}

#pragma mark --- 该方法不是协议中的方法啊

// 点击空白, 回收键盘

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    UIView *containerView = [self.window viewWithTag:100];

    UITextField *textFD = (UITextField *)[containerView viewWithTag:200];

    [textFD resignFirstResponder];

    

}

posted @ 2015-10-21 20:29  kevin丶涛  阅读(201)  评论(0编辑  收藏  举报