FUIFormCollectionViewController

open class FUIFormCollectionViewController : UICollectionViewController

When FUIListPickerCollectionViewCells are to be used in an application, the application’s implementation of UICollectionViewController that hosts these FUIListPickerCollectionViewCells must be a subclass of this FUIFormCollectionViewController. FUIFormCollectionViewController hides all the complexity and interactions for handling FUIListPickerCollectionViewCell.

The application’s implementation of the UICollectionViewController needs to only implement the following functions:


 class FormCollectionViewCellTestTVC: UICollectionViewController {
    override func viewDidLoad() {
        // MUST: Call viewDidLoad function of super class.
        super.viewDidLoad()

        // Register FUIFormCells that will be used
        self.collectionView.register(FUIListPickerCollectionViewCell.self, forCellWithReuseIdentifier: FUIListPickerCollectionViewCell.reuseIdentifier)
        ...
    }

    override func numberOfSections(in collectionView: UICollectionView) -> Int {
        // Return how many sections are in the collection
        return ...
    }

    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        // Return number of items in each section
        return ...
    }

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUIListPickerCollectionViewCell.reuseIdentifier, for: indexPath) as! FUIListPickerCollectionViewCell
        cell.keyName = "Pick One"
        cell.isEnabled = true
        // MARK:  implement onChangeHandler
        cell.onChangeHandler = { newValue in
            myObject.title = newValue
        }
        return cell
    }

  • The effective UINavigationController.

    The developer could set this to the UINavigationController for this view controller. If the 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 }