日期:2014-05-16  浏览次数:20462 次

searchBarTextDidBeginEditing方法在pop的时候又被执行

好久没写blog了,最近太忙了,闲暇的时候就懒得写了,导致迟迟没有更新,哈哈。

今天遇到个奇怪的问题,没有找到原因,但是找到了解法…… 囧啊~!


事情的经过是这样的,

1.点击UISearchBar的时候会触发

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {

  [self.navigationController pushViewController:pvc animated:YES];

}

此步正常

2.当我pop回UISearchBar的这个页面的时候,searchBarTextDidBeginEditing方法又被调用了一次,我直接就晕菜了。

后来上网找了个文章:http://stackoverflow.com/questions/3565678/which-event-get-called-when-we-hit-uisearchbar

大致的意思是说pop回来的时候界面的UISearchBar又被激活了……。

3.之后我再自定义push的动画效果的时候发现居然不存在上述的bug了,原因是我把

  [self.navigationController pushViewController:pvc animated:NO];

的animated设成NO了。

具体原因没找到,哪位大虾能告诉在下原因?