FUIFormTableViewController

open class FUIFormTableViewController : UITableViewController, FUIFormCellResponderDelegate, FUIFormCellNavigationDelegate

When FUIFormCells are to be used in an application, application’s implementation of UITableViewController that hosts these FUIFormCells must be a subclass of this FUIFormTableViewController. FUIFormTableViewController hides all the complications and interactions for handling all different types of FUIFormCells.

Application’s implementation of the UITableViewController needs to only implement the following functions:


 class FormCellTestTVC: FUIFormTableViewController {
    override func viewDidLoad() {
        // MUST: Call viewDidLoad function of super class.
        super.viewDidLoad()

        // Register FUIFormCells that will be used
        self.tableView.register(FUITitleFormCell.self, forCellReuseIdentifier: FUITitleFormCell.reuseIdentifier)
        ...
    }

    override func numberOfSections(in tableView: UITableView) -> Int {
        // Return how many section in the table
        return ...
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // Return number of rows in each section
        ...
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // Return the cell to be used at the IndexPath specified
        let cell = tableView.dequeueReusableCell(withIdentifier: FUITitleFormCell.reuseIdentifier, for: indexPath) as! FUITitleFormCell
        cell.value = "Work Request"

        cell.isEditable = true
        // MARK:  implement onChangeHandler
        cell.onChangeHandler = { newValue in
            myObject.title = newValue
        }
        return cell
    }

In addition, if there are some other actions on the table view, it is required that the action functions should also call function endEditing of the table view with the force parameter to true so that all editing cells have its onChangeHandler called. For example, the function didSaveTapped below is the action when the Save button tapped:

    @IBAction func didSaveTapped(_ sender: AnyObject) {
        self.tableView.endEditing(true)

        // save object ...
    }

  • The effective UINavigationController.

    Developer could set this to the UINavigationController for this view controller. If developer did not set this value, the UINavigationController of this view controller will be returned if it is not nil. Otherwise, the root UINavigationController from the keyWindow, if any, will be returned.

    Declaration

    Swift

    public var effectiveNavigationController: UINavigationController? { get set }