0

I have a SearchDisplayViewController that has the search result tableview that appears after you click the searchbar and type some characters. I am wondering if it is possible to have the searchresult tableview before you type any characters? I will post some related code below.

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return 1;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
    }

    return cell;
}
Akshit Zaveri
  • 4,166
  • 6
  • 30
  • 59
This Is
  • 137
  • 7
  • 1
    what do you want to display if searchbar is empty ? – Akshit Zaveri Nov 06 '13 at 13:44
  • If the search bar is empty, I would like one cell to say location. Since I can use it to show a certain location – This Is Nov 06 '13 at 13:48
  • Fill the searchResultArray with objects you wan to show! If you want to show no location cell.. its basically return (searchResultArray.count=0)?1:searchResultArray.count; in -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; method – Chamira Fernando Nov 06 '13 at 13:48
  • just check if your array for `tableView` is empty then fill it with the location data that you want. @ThisIs – Akshit Zaveri Nov 06 '13 at 13:49

0 Answers0