UISearchBar 点击取消回到原来位置时会跳动的解决方法

今天改动项目里面測试给提的bug。有一个bug就是当点击UISearchBar的取消buttonUISearchBar回到原来位置时会发生偏差50像素左右的跳动,细致看看前面几个程序写的那个页面,也没有发现UISearchBar的代理方法
-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{
    
}

去网上找了半天,才发现有一个帖子里说在viewDidLoad中加入这么两句代码就能够

[self setAutomaticallyAdjustsScrollViewInsets:YES];
[self setExtendedLayoutIncludesOpaqueBars:YES];
只是没给出详细的原因。仅仅是说可能是uikit中的一个错误,只是在查看的过程中也发现还有其它的地方也会出现这个错误,http://blog.csdn.net/yongyinmg/article/details/23861853

解决这个问题的帖子:http://stackoverflow.com/questions/20565980/uisearchbar-in-uitableviewheader-strange-animation-on-ios-7-8

原文地址:https://www.cnblogs.com/yfceshi/p/7259310.html