Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it not possible to put UISearchBar in UITableView header?

I am trying to accomplish this:

Consider a table view with Search Bar on its header.Table view gets refreshed whenever string is searched.

I am having 2 classes

TableViewController(UIViewController subclass)

contains UITableView -That shows the table whose

header view of the table is loaded from the Header class(UIToolBar subclass)

.

Header(header of the UITableView)
-Contains UISearchBar and its delegate

The

UISearchBarDelegates call back a function in TableViewController

that calls

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation  

which causes App to crash

The function call stack frame is as follows

[UITableView reloadSections:withRowAnimation:]  
[TableViewController functionThatCallsReloadSection]  
[Header searchBarSearchButtonClicked:]  

The reloadSection is causing the App to crash .Any ideas why its happening so?

Is it because the delegate function is still active on the stack while the the table view header is reloaded??

I am not changing any anything related to the tableview (no change in the number of rows or sections).All i am trying to doing is to just reload the table view.

Edited: I am trying to do all these things in iPad,which provides a popover while using UISearchDisplayController which i dont want to use.I already have a table view which i want to refresh once the text is entered and search button is hit,using the search delegate. The only problem is that once i call [UITableView reloadSection:] in the search delegate of UISearchBar(UISearchBar is located on the header of the UITableView that i want to reload) the app crashes.

like image 777
prajul Avatar asked Mar 12 '12 19:03

prajul


1 Answers

I was able to fix the problem by using the tableViewHeader instead of loadind the table view header using the table view header delegate method where i used a pointer thats initialised to the table view header.

like image 126
prajul Avatar answered Sep 30 '22 13:09

prajul