ios - Search Results in a UITableView Swift -
i have search bar searching array of names, array of names not listed on screen. when user searches, need height of table view set based on how many results returned.
my search functionality works, want have table view of results show if there results.
i thinking somewhere in function set table view's height found setting it's rows height.
func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { // return number of rows in section. tableview.rowheight = 50.0 return results.count }
func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { if results.count tableview.hidden = false else tableview.hidden = true return results.count } there may typo error, can use logic, have used many times. on each reload of table, table data source count whether there records in array or not. if records show tableview, if not hide. can add nice animation alpha 0 1 or 1 0. , if have taken reference of tableview iboutlet use tableview name overhere.
Comments
Post a Comment