Hello I added UISearchbar in navigation bar of collection view controller. Search wroks fine. But when search result pop-up window is closed, and I begib search once more space between first cell of results and window header is increasing. And it's happaning each time (screens added). When I return backward from collection view screen to previous screen and onward everythings starts from begingin. First search is ok, second has a space and so on.
adding searchbar:
void setupGridSearch ()
{
if (gridCollection == null)
throw new NullReferenceException ("field gridCollection reference is null");
search = new ReportGridSearch<ReportGridCollection> (gridCollection);
searchBar = new UISearchBar (new RectangleF (0, 0, 300, 50)) {
Placeholder = Constants.ReportGridSearchBarPlaceholderText,
ShowsBookmarkButton = false,
ShowsCancelButton = false,
ShowsSearchResultsButton = false,
};
var srd = new PeportCollectionViewSearchResultDelegate (this, search);
srd.RowSelectedEvent += searchResultRowSelected_RowSelectedEvent;
searchController = new UISearchDisplayController (searchBar, this) {
SearchResultsSource = new ReportGridSearchResultSource (search),
Delegate = new ReportGridSearchDelegate (gridCollection, search),
SearchResultsDelegate = srd,
SearchResultsTitle = Constants.ReportGridSearchResultsTitle,
};
UIBarButtonItem sbi = new UIBarButtonItem (searchBar);
NavigationItem.RightBarButtonItem = sbi;
}
search result source:
public class ReportGridSearchResultSource : UITableViewSource
{
List<string> resultList;
ReportGridSearch<ReportGridCollection> search;
const string cellIdentifier = "TableCell";
const string headerIdentifier = "TableHeader";
public ReportGridSearchResultSource (ReportGridSearch<ReportGridCollection> search)
{
this.search = search;
}
public override int RowsInSection (UITableView tableview, int section)
{
return search.SearchResult.Count;
}
public override int NumberOfSections (UITableView tableView)
{
return 1;
}
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
var cell = tableView.DequeueReusableCell (cellIdentifier);
// if there are no cells to reuse, create a new one
if (cell == null)
cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
cell.TextLabel.Text = search.SearchResult.ElementAt (indexPath.Row).Value;
return cell;
}
}
May be somebody had same issue?