I have a UITableViewController
subclass with sections. The sections are showing with the default style (no rounded corners). How can I set the TableView style to grouped in the code? I'm not using Interface Builder for this, so I need something like
[self.tableView setGroupedStyle]
I searched on Stack Overflow, but couldn't come up with an answer.
A plain-style table view is an unbroken list; a grouped table view has visually distinct sections.
You cannot change the tableView style once set. So the only way is set the style during initialisation.
You can change the space between tableviewcells themselves by: [myTableView setSectionHeaderHeight:0]; [myTableView setSectionFooterHeight:25];
Adding Search Bar on TableViewAdd the UISearchBar at the top of your UITableView. … and give the name searchBar. In the ViewController add a Boolean called searching to know when to switch between the full list of items and the list of items from the searching results.
You can do the following:
UITableView *myTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
Swift 3:
let tableView = UITableView.init(frame: CGRect.zero, style: .grouped)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With