UserViewController
class UserViewController : UIViewController, UITableViewDelegate, UITableViewDataSource
UserViewController is used to control the user page view
-
This is a
UITableViewthat displays user informationDeclaration
Swift
@IBOutlet var tableView: UITableView! -
This is a self-defined view called
UserHistoryView, which is based onUIViewDeclaration
Swift
@IBOutlet var historyView: UserHistoryView! -
This is a list of menu titles that is displayed in
UITableViewDeclaration
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) -> IntParameters
tableViewThe table-view object requesting this information.
indexPathAn 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) -> UITableViewCellParameters
tableViewA table-view object requesting the cell.
indexPathAn index path locating a row in tableView.
Return Value
An object inheriting from
UITableViewCell that the table view can use for the specified row.UIKitraises 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
tableViewA table-view object informing the delegate about the new row selection.
indexPathAn index path locating the new selected row in tableView.
-
Called after the controller's view is loaded into memory. Load
customisationDeclaration
Swift
override func viewDidLoad()
UserViewController Class Reference