UserViewController
class UserViewController : UIViewController, UITableViewDelegate, UITableViewDataSource
UserViewController
is used to control the user page view
-
This is a
UITableView
that displays user informationDeclaration
Swift
@IBOutlet var tableView: UITableView!
-
This is a self-defined view called
UserHistoryView
, which is based onUIView
Declaration
Swift
@IBOutlet var historyView: UserHistoryView!
-
This is a list of menu titles that is displayed in
UITableView
Declaration
Swift
let menuTitles: [String]
-
Default number of items = 6, including user title
Declaration
Swift
let defaultItems: Int
-
User information
Declaration
Swift
var user: User
-
The offset of the last Content used to determine the scroll action
Declaration
Swift
var lastContentOffset: CGFloat
-
Control the refresh process
Declaration
Swift
var refreshControl: UIRefreshControl
-
Customise View
- Setup
HistoryView
- Setup
TableView
Declaration
Swift
func customisation()
- Setup
-
Scroll the menu, this will be called when a notification is being sent with value didSelectMenu
Declaration
Swift
@objc func scrollViews(notification: Notification)
-
Show History View
Declaration
Swift
func showHistory()
-
Set User for view
Declaration
Swift
func setUser(user: User)
-
Refresh the page, when a notification is being sent with value refresh
Declaration
Swift
@objc func refresh(sender _: Any)
-
Tells the data source 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 source 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.
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
Declaration
Swift
override func viewDidLoad()