在UIScrollView触摸事件上重新调整键盘

时间:2014-05-27 12:33:53

标签: ios objective-c xcode uiscrollview

我在UITextField中有一个UIButtonUIScrollView。我想在用户触摸UITextField之外时调用键盘。如果我实现UITapGestureRecognizer,那么按钮不起作用。任何帮助将不胜感激。谢谢提前

1 个答案:

答案 0 :(得分:0)

试试这个..

-(void)viewWillAppear:(BOOL)animated{
    UITapGestureRecognizer *tapScroll = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapped)];
    tapScroll.cancelsTouchesInView = NO;
    [self.scrollView addGestureRecognizer:tapScroll];
}
- (void) tapped {
    [self.view endEditing:YES];
}