Vanoshan Ramdhani
Vanoshan Ramdhani

Reputation: 63

Is there a right way to implement TableView

I'm learning swift and I have gone through tutorials where some developers delete the View Controller entirely and just drag in a TableViewController and start using that. While other developers in tutorials create a TableView from within the View Controller.

Is it better to delete the View Controller and add a Table View Controller or just work with a TableView within the View Controller?

Upvotes: 0

Views: 113

Answers (2)

dahiya_boy
dahiya_boy

Reputation: 9503

It is all about the requirement. Both are correct way. Don't be confuse.

  • When you using TableViewController then it only behaves with the UITableview. i mean controller totally dedicated itself as tableview.

  • When you using TableView inside UIViewController then you can create whole UI deign in your own way.

Note: As you'r new so I suggest you to go with TableView Inside UIViewController because you can achieve any type of UI with this even you can create ditto functionality(UITableViewController) with this but vice versa not true.

For eg.

tableView inside UIviewController

enter image description here

Upvotes: 3

Catherine
Catherine

Reputation: 682

You can do it in either way. If your viewcontroller is going to have a tableview alone, then u can use a UITableViewController or else use UIViewController and set the delegates and datasource

Upvotes: 0

Related Questions