Introduction to UITableView in Swift:
UITableView is the basic control used in mobile apps. In this tutorial, we will learn how to create UITableView in swift language. All the delegates for the UITableview are same only syntax changes are there in swift language. Let us start how to create UITableView in swift.
Implementation of code for UITableView:
Create a single view application template and press next button
Name your project “UITableView-Swift” and select development language as Swift language
Chose the location to save your project files and press create.
Now as we successfully created our project, open Main.storyboard and drag UITableView on to the view. Add constraints (assuming that you know auto-layout) to UITableView. You can change your view’s screen size from attributed inspector as shown in below image
Open ViewController.swift file, create IBOutlet for our UITableView and declare our cellIdentifier.
Open Main.storyboard file and connect IBOutlet created in previous step with UITableView. Also connect UIItableView’s delegate and datasource outlets with ViewController.
Open ViewController.swift file, here we will implement our UITableView delegates and data source
methods as shown below
Run your app and you will see UITableView showing text inside rows. You can modify the code as per your needs.
Download Code for UITableView in swift: UitableView-Swift Source Code
Where to go from here:
In this tutorial you learned, how to create UITableView in swift language. I hope you enjoyed this post on How To create UITableview in Swift – Tutorial. If you have any questions, please feel free to comment.