HomeViewController
class HomeViewController : UIViewController, UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate
Home View Controller controls the home page views and operation
-
This is a
UITableView
used to displayContent
as cellsDeclaration
Swift
@IBOutlet var tableView: UITableView!
-
This is a variable to store list of
Contents
Declaration
Swift
var contents: [Content]
-
This is the offset of the last Content used to determine the scroll action
Declaration
Swift
var lastContentOffset: CGFloat
-
This is a refresh control
Declaration
Swift
var refreshControl: UIRefreshControl
-
Customise View
- Setup
tableView
Declaration
Swift
func customisation()
- Setup
-
Refresh the page and reload
content
, when a notification is being sent with value refreshDeclaration
Swift
@objc func refresh(sender _: Any)
-
Tells the list of
Content
s to return the number of rows in a given section of a table view.Declaration
Swift
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int
Parameters
tableView
The table-view object requesting this information.
indexPath
An index number identifying a section in tableView.
Return Value
The number of rows in section.
-
Asks the list of
Centent
for a cell to insert in a particular location of the table view.Declaration
Swift
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
Parameters
tableView
A table-view object requesting the cell.
indexPath
An index path locating a row in tableView.
Return Value
An object inheriting from
UITableViewCel
l that the table view can use for the specified row.UIKit
raises an assertion if you return nil. -
Tells the delegate that the specified row is now selected. And send open notification
Declaration
Swift
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
Parameters
tableView
A table-view object informing the delegate about the new row selection.
indexPath
An index path locating the new selected row in tableView.
-
Called after the controller's view is loaded into memory. Load
customisation
methodDeclaration
Swift
override func viewDidLoad()