Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a UITableView to grouped style

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.

like image 673
nevan king Avatar asked Jun 17 '09 12:06

nevan king


People also ask

What is the difference between plain and grouped UITableView?

A plain-style table view is an unbroken list; a grouped table view has visually distinct sections.

How do I change the TableView style programmatically in Swift?

You cannot change the tableView style once set. So the only way is set the style during initialisation.

How do you remove the blank space at the top of a grouped UITableView?

You can change the space between tableviewcells themselves by: [myTableView setSectionHeaderHeight:0]; [myTableView setSectionFooterHeight:25];

How do I add a search bar to UITableView?

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.


1 Answers

You can do the following:

UITableView *myTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; 

Swift 3:

let tableView = UITableView.init(frame: CGRect.zero, style: .grouped) 
like image 159
Lior Avatar answered Oct 03 '22 08:10

Lior