Hide UISearchBar of UISearchDisplayController

谁说我不能喝 提交于 2019-12-04 11:26:11

I guess this is not the correct approach, but it works for me :) to make it hidden:

CGRect searchFrame = self.searchDisplayController.searchBar.frame;
searchFrame.size.height = 0;

self.searchDisplayController.searchBar.frame = searchFrame;
self.searchDisplayController.searchBar.hidden = YES;

To "reveal" it again:

searchFrame.size.height = 44;
self.searchDisplayController.searchBar.frame = searchFrame;
self.searchDisplayController.searchBar.hidden = NO;

I'm not sure if this works with autolayout, never tried it. (Also this is on Xcode < 5, iOS<7)

I have figured that out. My first problem was the first click on tableview row did not respond. That was for i have mistaken didSelectRowAtIndexPath for didDeselectRowAtIndexPath. What a silly mistake and I suffered for hours...:(

The second problem was for I was writing the hiding and frame changing code in viewDidLoad function, I moved the code to viewDidAppear function. Now the codes are working properly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!