Hide empty cells in UITableView

后端 未结 7 827
春和景丽
春和景丽 2021-01-11 12:47

I have a searchable tableview, but would like to only display the number of cells that are returned once a user starts a search. For instance, if a user types in a charecter

相关标签:
7条回答
  • 2021-01-11 13:30
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
           if (([array count]*65) > [UIScreen mainScreen].bounds.size.height - 66)
            {
              Table.frame = CGRectMake(0, 66, self.view.frame.size.width, [array count]*65)); 
            }else
           {
             Table.frame = CGRectMake(0, 66, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height - 66);
            }
            return [array count];
    }
    

    here 65 is the height of the cell and 66 is the height of the navigation bar in UIViewController.

    0 讨论(0)
提交回复
热议问题