Hide empty cells in UITableView

后端 未结 7 890
春和景丽
春和景丽 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:22

    Hiding an empty cells in Swift

    Swift 3 Edition

     override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        self.tableView.tableFooterView = UIView(frame: CGRect.zero)
    }
    

    Swift 2 Edition

     override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
    
        self.tableView.tableFooterView = UIView(frame: CGRectZero)
    }
    

提交回复
热议问题