ios开发--键盘隐藏

-(void)setupKeyBoard

{

    UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];

    tapGr.cancelsTouchesInView = NO;

    [self.view addGestureRecognizer:tapGr];

}

 

-(void)viewTapped:(UITapGestureRecognizer*)tapGr

{

    [_iphoneTextField resignFirstResponder];

    [_passwordText resignFirstResponder];

}

 

或者

//设置键盘隐藏

<UIGestureRecognizerDelegate>

-(void)setupKeyBoard

{

UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleFingerEvent:)];

singleFingerOne.numberOfTouchesRequired = 1; //手指数

singleFingerOne.numberOfTapsRequired = 1; //tap次数

singleFingerOne.delegate= self;

[self.view addGestureRecognizer:singleFingerOne];

}

-(void)handleSingleFingerEvent:(UITapGestureRecognizer*)tap

{

self.loginTableView.contentSize = CGSizeMake(0,0);

[self.view endEditing:YES];

}

阅读更多
想对作者说点什么? 我来说一句

键盘隐藏demo

2013年04月27日 59KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭