FXForms provides default cell implementations for all supported fields. You may wish to provide additional cell classes for custom field types, or even replace all of the FXForm cells with custom versions for your application.
There are two levels of customisation possible for cells. The simplest option is to subclass one of the existing FXFormCell classes, which all inherit from FXFormBaseCell. These cell classes contain a lot of logic for handling the various different field types, but also expose the views and controls used, for easy customisation.
When subclassing an existing cell type, you can override the setUp, update and didSelectWithTableView:controller: methods (optionally calling [super ...] if you want to inherit the original cell's behaviors). The setUp method will be called once when the cell is created, and the update method will be called each time the field value is updated.
If you already have a base cell class and don't want to base your cells on FXFormBaseCell, you can create an FXForms-compatible cell from scratch by subclassing UITableViewCell and adopting the FXFormFieldCell protocol.
Your custom cell must have a property called field, of type FXFormField. FXFormField is a wrapper class used to encapsulate the properties of a field, and also provides a way to set and get the associated form value (via the field.value virtual property). You cannot instantiate FXFormField objects directly, however they can be accessed and enumerated via methods on the FXFormController.
Once you have created your custom cell, you can use it as follows:
If your cell is used only for a few specific fields, you can use the FXFormFieldCell property to use it for a particular form field
If your cell is designed to handle a particular field type (or types), you can tell the formController to use your custom cell class for a particular type using the -registerCellClass:forFieldType: method of FXFormController.
If your cell is designed to handle a particular field value class (or subclass), you can tell the formController to use your custom cell class for a particular value class using the -registerCellClass:forFieldClass: method of FXFormController.
* If you want to completely replace all cells with your own classes, use the -registerDefaultFieldCellClass: method of FXFormController. This replaces all default cell associations for all field types with your new cell class. You can then use -registerCellClass:forFieldType: to add additional cell classes for specific types.
I read the document above , it is too difficult to follow , would you like to give some example codes to show how to use the two kind of custom cells ? thank you very much.
Custom cells
FXForms provides default cell implementations for all supported fields. You may wish to provide additional cell classes for custom field types, or even replace all of the FXForm cells with custom versions for your application.
There are two levels of customisation possible for cells. The simplest option is to subclass one of the existing
FXFormCell
classes, which all inherit fromFXFormBaseCell
. These cell classes contain a lot of logic for handling the various different field types, but also expose the views and controls used, for easy customisation.When subclassing an existing cell type, you can override the
setUp
,update
anddidSelectWithTableView:controller:
methods (optionally calling [super ...] if you want to inherit the original cell's behaviors). ThesetUp
method will be called once when the cell is created, and theupdate
method will be called each time the field value is updated.If you already have a base cell class and don't want to base your cells on
FXFormBaseCell
, you can create an FXForms-compatible cell from scratch by subclassingUITableViewCell
and adopting theFXFormFieldCell
protocol.Your custom cell must have a property called field, of type
FXFormField
.FXFormField
is a wrapper class used to encapsulate the properties of a field, and also provides a way to set and get the associated form value (via thefield.value
virtual property). You cannot instantiateFXFormField
objects directly, however they can be accessed and enumerated via methods on theFXFormController
.Once you have created your custom cell, you can use it as follows:
FXFormFieldCell
property to use it for a particular form field-registerCellClass:forFieldType:
method of FXFormController.-registerCellClass:forFieldClass:
method of FXFormController.* If you want to completely replace all cells with your own classes, use the
-registerDefaultFieldCellClass:
method ofFXFormController
. This replaces all default cell associations for all field types with your new cell class. You can then use-registerCellClass:forFieldType:
to add additional cell classes for specific types.I read the document above , it is too difficult to follow , would you like to give some example codes to show how to use the two kind of custom cells ? thank you very much.
What I want to do is :