Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController vs TableView

Tags:

What is the difference between dragging a Table View Controller into the storyboard vs dragging a UI View Controller and dragging a Table View inside that in xCode?

I know how to populate a table view controller in code.

- (UITableViewCell *)tableView:(UITableView *)tableView                       cellForRowAtIndexPath:(NSIndexPath *)indexPath; 

How do I populate a table view within a UI View Controller? What custom class do I delegate to the UI View? I cannot seem to put a tableViewController on it as it is only a ViewController with a table view...

I'd like to know this because I'd like to have objects other than the table in that view (i.e. a section of the view is for the table and the other section contains a label, an image, and a button.)

like image 271
lorenzoid Avatar asked Mar 14 '12 00:03

lorenzoid


People also ask

What is UITableViewController?

A view controller that specializes in managing a table view.

What is the difference between table View and table View Controller?

A TableView is just that a TableView (subclass of UIView). It can be added to a ViewController and resized, used alongside another view based object, etc.

What class does UITableView inherit from?

The appearance of the tableview is managed by UITableView class, which inherits UIScrollView. In tableview, the row is simulated by the object of the UITableViewCell class, which can be used to display the actual content. We can customize the tableview cells to display any content in the iOS application.

What is table View Controller in Swift?

The TableViewController provides the tableview property to access the tableview in the storyboard. It conforms to the UITableViewDelegate and UITableViewDatasource protocol by default. The subclass overrides the delegate and DataSource methods to provide the tableview implementation.

What is a uitableviewcontroller?

A view controller that specializes in managing a table view. Subclass UITableViewController when your interface consists of a table view and little or no other content. Table view controllers already adopt the protocols you need to manage your table view's content and respond to changes.

When to use subclass uitableviewcontroller in Salesforce?

Subclass UITableViewController when your interface consists of a table view and little or no other content. Table view controllers already adopt the protocols you need to manage your table view's content and respond to changes.

How to use the Table View Controller?

The Table View Controller manages its Table View consisting of Table View Cells and an empty Content View in the cell: Select the section using the outline or with Shift + Click. Set Countries as Header text: Select the cells by Shift + clicking and configure Basic as Style for all cells. A Basic Cell has one Label by default: Run the app with ⌘R.

How do I create a UITableView project in Xcode?

This tutorial demonstrates common use cases for the UITableView and UITableViewController classes. For this tutorial you need basic programming skills and know how to use Xcode. Run Xcode and create a new project with File » New » Project ⌘⇧N. Select iOS » Application » App: Name the app “ Countries ”.


2 Answers

Populating a UITableView inside of a UIViewController is no different than populating a UITableView inside of a UITableViewController. You just have to make sure you implement the required datasource and delegate methods. You also need to be sure to assign the UIViewController as the delegate and the datasource for that UITableView.

If you want objects other than the table, then you should us a UIViewController. In fact, I rarely use the UITableViewController any more just in case I need to add other objects.

like image 175
sosborn Avatar answered Sep 20 '22 15:09

sosborn


I found another difference too . While using a UITableViewController , which has UIScrollView in it , the view scrolls up when keyboard moves up . This doesn't happen with UIViewController as you need separate methods for View scrolling up and down .

You can also take a look at this
https://stackoverflow.com/a/14465669/5553647

like image 34
user5553647 Avatar answered Sep 23 '22 15:09

user5553647