0

I have a uiview with a button on that. When click on that button i am showing a subview.

The subview contains a table view and a search display controller. when i enter something on search bar it will be showing the search result tableview.

once search is done and going back to the superview and again come back to subview, the table view that displays all the records is not scrollable and also the search bar contains the text that has been entered before, that is search bar contains text but the tableview is not search result table view.

This issue will not come if i click on Cancel button of searchbar, without clicking on cancel button if i go back to superview, the issue arises.

priyanka vijesh
  • 227
  • 1
  • 3
  • 7

1 Answers1

0

When you show yourTableview with searchBar at that time set bellow code..

searching = NO; // if you use this BOOL value.. 

and also clear the text of UISearchBar's text i.e.

searchBar.text = @"";

and after reloadData of UITableView

-(void)showSearchTable   // its an example
{
     searching = NO;
     searchBar.text = @"";
     [yourTableView reloadData];
}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • but ViewWillAppear will not get called when we hide and show the view correct? – priyanka vijesh Oct 15 '12 at 08:08
  • but you say when i go back and push again at that time you see the text in textfield and data not display proper so i give u this logic but tell me what is the main pro?? what u want?? – Paras Joshi Oct 15 '12 at 08:19
  • oh sorry sorry i understand now just do this coding when you click on any button which through you show the searchbar tableview.. – Paras Joshi Oct 15 '12 at 08:23
  • going back means hiding and showing subview.I am staying on the same view controller... – priyanka vijesh Oct 15 '12 at 08:23
  • Dear, when you show the tablview with searchbar at that time first clear the searchbar text is clear and reload table .. try this ... – Paras Joshi Oct 15 '12 at 08:25
  • hi..i want to perform the same action that happens when click on cancel button of search bar on my button click.i dont know what all things happen when click on cancel button.. – priyanka vijesh Oct 15 '12 at 09:51