2013-09-27 47 views
0

后辞职键盘我实现延迟,当我滚动tableview中

scrollViewWillBeginDragging:(UIScrollView *)scrollView{ 
    [searchBar resignFirstResponder];} 

当我开始滚动搜索页面上实现代码如下,以消除键盘。但是在表格平滑滚动之前有一个扭曲和延迟。帮帮我?

回答

2

尝试在您的tableView设置这样的:

self.tableView.delaysContentTouches = NO; 

    [self.tableView.view endEditing:YES]; 

代替

[searchBar resignFirstResponder]; 

该属性默认为YES。它将表格视图单元的内容延迟几分之一秒,以帮助识别轻敲和拖动之间的差异。

+0

我会给你一个投票,但事实证明你可以做两件事,一个是禁用键盘解雇通知视图的动画。或者实际上这是一个模拟器问题,因为我尝试了设备上的代码,并且没有扭结。 – Nate

+0

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willHideKeyboard :) name:UIKeyboardWillHideNotification object:nil]; (无效)willHideKeyboard:(NSNotification *)notification {UIView setAnimationsEnabled:NO]; } –

1

UIKeyboardAnimationDurationUserInfoKey是动画持续时间的常量字符串标识符,因此存在启用和禁用动画的地方。

[[NSNotificationCenter defaultCenter] addObserver:self 
           selector:@selector(willHideKeyboard:) 
            name:UIKeyboardWillHideNotification 
            object:nil]; 

- (void)willHideKeyboard:(NSNotification *)notification { 
     [UIView setAnimationsEnabled:NO]; 
    } 

希望这可以帮助你。