SCCellActions Class Reference
Inherits from | NSObject |
Declared in | SCCellActions.h |
Overview
This class hosts a set of cell action blocks. Once an action is set to a desired code block, it will execute the block as soon as the action occurs.
Tasks
Actions
-
willStyle
Action gets called before the cell gets automatically styled using the provided theme.
property -
willConfigure
Action gets called before the cell is configured.
property -
didLayoutSubviews
Action gets called after the cell has laid out all its subviews.
property -
willDisplay
Action gets called before the cell is displayed.
property -
lazyLoad
Action gets called after the cell has been displayed and the table view has stopped scrolling.
property -
willSelect
Action gets called when the cell is about to be selected.
property -
didSelect
Action gets called when the cell has been selected.
property -
willDeselect
Action gets called when the cell is about to be deselected.
property -
didDeselect
Action gets called when the cell has been deselected.
property -
accessoryButtonTapped
Action gets called when the cell’s accessory button has been tapped.
property -
returnButtonTapped
Action gets called when the cell keyboard’s return button has been tapped.
property -
valueChanged
Action gets called when the cell’s bound property value has changed via a cell control or a detail model.
property -
valueIsValid
Action gets called when the cell’s value needs to be validated.
property -
didLoadBoundValue
Action gets called whenever a cell’s bound value has been loaded.
property -
willCommitBoundValue
Action gets called before a cell’s bound value is committed to its bound object.
property -
customButtonTapped
Action gets called whenever a cell’s user defined custom button is tapped.
property
Detail Model Actions
-
detailViewController
Action gets called to give you the chance to return a custom detail view controller for the cell.
property -
detailTableViewModel
Action gets called to give you the chance to return a custom detail model for the cell’s detail view controller.
property -
detailModelCreated
Action gets called right after the cell’s detail model is created, before configuration is set or any sections are added.
property -
detailModelConfigured
Action gets called after the cell’s detail model is fully configured, including the addition of all automatically generated sections.
property -
detailModelWillPresent
Action gets called when the cell’s detail model is about to be presented in its own view controller.
property -
detailModelDidPresent
Action gets called when the cell’s detail model has been presented in its own view controller.
property -
detailModelWillDismiss
Action gets called when the cell’s detail model’s view controller is about to be dismissed.
property -
detailModelDidDismiss
Action gets called when the cell’s detail model’s view controller has been dismissed.
property
Miscellaneous
-
– setActionsTo:overrideExisting:
Method assigns all the actions of another ‘SCCellActions’ class to the current one.
Properties
accessoryButtonTapped
Action gets called when the cell’s accessory button has been tapped.
@property (nonatomic, copy) SCCellAction_Block accessoryButtonTapped
Discussion
Example:
cellActions.accessoryButtonTapped = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ accessory button has been tapped.", indexPath);
};
Note: For this action to get called, you must first have the cell’s accessory button appear by setting its accessoryType property to UITableViewCellAccessoryDetailDisclosureButton.
Declared In
SCCellActions.h
customButtonTapped
Action gets called whenever a cell’s user defined custom button is tapped.
@property (nonatomic, copy) SCCellCustomButtonTappedAction_Block customButtonTapped
Discussion
This action is typically used to easily provide a custom behavior for the cell’s custom button(s).
Example:
cellActions.customButtonTapped = ^(SCTableViewCell *cell, NSIndexPath *indexPath, UIButton *button)
{
NSLog(@"Custom button with tag:%i has been tapped for cell at indexPath:%@.", button.tag, indexPath);
};
Declared In
SCCellActions.h
detailModelConfigured
Action gets called after the cell’s detail model is fully configured, including the addition of all automatically generated sections.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelConfigured
Discussion
This action is typically used to add additional custom sections, or modify the already existing automatically generated ones.
Example:
cellActions.detailModelConfigured = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
SCTableViewSection *customSection = [SCTableViewSection section];
SCCustomCell *customCell = [SCCustomCell cellWithText:@"Custom Cell"];
[customSection addCell:customCell];
[detailModel addSection:customSection];
};
Note: In general, it is easier (and more recommended) to add your custom sections and cells using the data definitions, instead of using this action to do so. For more information, please refer to SCDataDefinition and SCCustomPropertyDefinition.
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
Declared In
SCCellActions.h
detailModelCreated
Action gets called right after the cell’s detail model is created, before configuration is set or any sections are added.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelCreated
Discussion
This action is typically used to initially configure the detail model (like set a custom tag for example). Most of the model’s settings can also be configure in the detailModelConfigured action.
Example:
cellActions.detailModelCreated = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
detailModel.tag = 100;
};
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
See Also
Declared In
SCCellActions.h
detailModelDidDismiss
Action gets called when the cell’s detail model’s view controller has been dismissed.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelDidDismiss
Discussion
Example:
cellActions.detailModelDidDismiss = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
NSLog(@"Detail model has been dismissed.");
};
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
Declared In
SCCellActions.h
detailModelDidPresent
Action gets called when the cell’s detail model has been presented in its own view controller.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelDidPresent
Discussion
Example:
cellActions.detailModelDidPresent = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
NSLog(@"Detail model has been presented.");
};
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
Declared In
SCCellActions.h
detailModelWillDismiss
Action gets called when the cell’s detail model’s view controller is about to be dismissed.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelWillDismiss
Discussion
Example:
cellActions.detailModelWillDismiss = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
NSLog(@"Detail model will be dismissed.");
};
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
Declared In
SCCellActions.h
detailModelWillPresent
Action gets called when the cell’s detail model is about to be presented in its own view controller.
@property (nonatomic, copy) SCDetailModelCellAction_Block detailModelWillPresent
Discussion
This action is typically used to further customize the detail model’s view controller.
Example:
cellActions.detailModelWillPresent = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
{
detailModel.viewController.title = @"My custom title";
};
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell.
Declared In
SCCellActions.h
detailTableViewModel
Action gets called to give you the chance to return a custom detail model for the cell’s detail view controller.
@property (nonatomic, copy) SCCellDetailTableViewModelAction_Block detailTableViewModel
Return Value
The custom detail model. The returned detail model should not be associated with any table views, as the framework will automatically handle this on your behalf. Note: returning nil ignores the implementation of this action.
Example:
cellActions.detailTableViewModel = ^SCTableViewModel*(SCTableViewCell *cell, NSIndexPath *indexPath)
{
SCTableViewModel *detailModel = nil;
if([cell isKindOfClass:[SCArrayOfObjectsCell class]])
{
detailModel = [SCArrayOfObjectsModel modelWithTableView:nil];
}
return detailModel;
};
Discussion
This action is typically used to provide your own custom detail model, instead of the one automatically generated by the cell. This might be needed in cases where the cell generates a detail SCArrayOfObjectsSection for example, and you need an SCArrayOfObjectsModel instead (to automatically generate sections for instance).
Note: It is much more common to use the detailViewController action instead, assigning the custom model in the custom view controller’s viewDidLoad method. This also gives you the chance to add a search bar (for example, to make use of SCArrayOfObjectsModel automatic searching functionality), or any other controls.
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell and SCArrayOfObjectsCell.
Declared In
SCCellActions.h
detailViewController
Action gets called to give you the chance to return a custom detail view controller for the cell.
@property (nonatomic, copy) SCCellDetailViewControllerAction_Block detailViewController
Return Value
The custom view controller. Must only be of type SCViewController or SCTableViewController. Note: returning nil ignores the implementation of this action.
Example:
cellActions.detailViewController = ^UIViewController*(SCTableViewCell *cell, NSIndexPath *indexPath)
{
MyCustomViewController *customVC = [[MyCustomViewController alloc] initWithNib:@"MyCustomViewController" bundle:nil];
return customVC;
};
Discussion
This action is typically used to provide your own custom detail view controller, instead of the one automatically generated by the cell.
Note: This action is only applicable to cells that generate detail views, such as SCSelectionCell and SCArrayOfObjectsCell.
Declared In
SCCellActions.h
didDeselect
Action gets called when the cell has been deselected.
@property (nonatomic, copy) SCCellAction_Block didDeselect
Discussion
Example:
cellActions.didDeselect = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ has been selected.", indexPath);
};
Declared In
SCCellActions.h
didLayoutSubviews
Action gets called after the cell has laid out all its subviews.
@property (nonatomic, copy) SCCellAction_Block didLayoutSubviews
Discussion
This action is typically used to change the subviews' layout.
Example:
cellActions.didLayoutSubviews = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
cell.textLabel.frame = CGRect(40, 20, 100, 40);
};
Declared In
SCCellActions.h
didLoadBoundValue
Action gets called whenever a cell’s bound value has been loaded.
@property (nonatomic, copy) SCCellBoundValueAction_Block didLoadBoundValue
Discussion
This action is typically used to do any customization to the loaded bound value.
Example:
cellActions.didLoadBoundValue = ^NSObject*(SCTableViewCell *cell, NSIndexPath *indexPath, NSObject *value)
{
// Make sure all string spaces are trimmed before displaying string.
NSString *stringValue = (NSStirng *)value;
NSString *trimmedString = [stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
return trimmedString;
};
Declared In
SCCellActions.h
didSelect
Action gets called when the cell has been selected.
@property (nonatomic, copy) SCCellAction_Block didSelect
Discussion
Example:
cellActions.didSelect = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ has been selected.", indexPath);
};
Declared In
SCCellActions.h
lazyLoad
Action gets called after the cell has been displayed and the table view has stopped scrolling.
@property (nonatomic, copy) SCCellAction_Block lazyLoad
Discussion
This action is typically used to load any cell content that is too expensive to load in willDisplay, such as retrieving data from a web service. This guarantees smooth and uninterrupted scrolling of the table view.
Example:
cellActions.lazyLoad = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
cell.imageView.image = [self retrieveImageForRowAtIndexPath:indexPath];
};
Declared In
SCCellActions.h
returnButtonTapped
Action gets called when the cell keyboard’s return button has been tapped.
@property (nonatomic, copy) SCCellAction_Block returnButtonTapped
Discussion
This action is typically used to override STV’s behavior when the return button is tapped, and define a custom one.
Example:
cellActions.returnButtonTapped = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
[self doMyCustomAction];
[cell.ownerTableViewModel moveToNextCellControl:YES];
};
Note: Action is only applicable to cells with controls that display a keyboard.
Declared In
SCCellActions.h
valueChanged
Action gets called when the cell’s bound property value has changed via a cell control or a detail model.
@property (nonatomic, copy) SCCellAction_Block valueChanged
Discussion
This action is typically used to provide a custom behavior when the cell’s value changes.
Example:
cellActions.valueChanged = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ value has changed to: %@.", indexPath, cell.boundValue);
};
Declared In
SCCellActions.h
valueIsValid
Action gets called when the cell’s value needs to be validated.
@property (nonatomic, copy) SCCellValueIsValidAction_Block valueIsValid
Return Value
Return TRUE if the current cell value is valid, otherwise return FALSE.
Example:
cellActions.valueIsValid = ^BOOL(SCTableViewCell *cell, NSIndexPath *indexPath)
{
BOOL valid = FALSE;
if([cell isKindOfClass:[SCTextFieldCell class]])
{
SCTextFieldCell *textFieldCell = (SCTextFieldCell *)cell;
// Make sure the password field is at least 8 characters long
if([textFieldCell.textField.text length] >= 8)
valid = TRUE;
}
return valid;
};
Discussion
This action is typically used to provide a custom cell value validation.
Declared In
SCCellActions.h
willCommitBoundValue
Action gets called before a cell’s bound value is committed to its bound object.
@property (nonatomic, copy) SCCellBoundValueAction_Block willCommitBoundValue
Discussion
This action is typically used to do any customization to the bound value before being committed.
Example:
cellActions.willCommitBoundValue = ^NSObject*(SCTableViewCell *cell, NSIndexPath *indexPath, NSObject *value)
{
// Make sure all string spaces are trimmed before committing the string.
NSString *stringValue = (NSStirng *)value;
NSString *trimmedString = [stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
return trimmedString;
};
Declared In
SCCellActions.h
willConfigure
Action gets called before the cell is configured.
@property (nonatomic, copy) SCCellAction_Block willConfigure
Discussion
This action is typically used to set the height of the cell, or any other attribute that will affect the cell’s configuration and layout.
Example:
cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
cell.height = 60;
};
Declared In
SCCellActions.h
willDeselect
Action gets called when the cell is about to be deselected.
@property (nonatomic, copy) SCCellAction_Block willDeselect
Discussion
Example:
cellActions.willDeselect = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ is about to be deselected.", indexPath);
};
Declared In
SCCellActions.h
willDisplay
Action gets called before the cell is displayed.
@property (nonatomic, copy) SCCellAction_Block willDisplay
Discussion
This action is typically used to set any attributes that will affect how the cell is displayed.
Example:
cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
cell.backgroundColor = [UIColor yellowColor];
};
Note: Changing the cell’s height property cannot be set here, and must be set in the willConfigure action instead.
Declared In
SCCellActions.h
willSelect
Action gets called when the cell is about to be selected.
@property (nonatomic, copy) SCCellAction_Block willSelect
Discussion
Example:
cellActions.willSelect = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"Cell at indexPath:%@ is about to be selected.", indexPath);
};
Declared In
SCCellActions.h
willStyle
Action gets called before the cell gets automatically styled using the provided theme.
@property (nonatomic, copy) SCCellAction_Block willStyle
Discussion
This action is typically used to set a custom themeStyle for the cell that is defined in the model’s theme file.
Example:
cellActions.willStyle = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
cell.themeStyle = @"MyCustomStyle";
};
See Also
Declared In
SCCellActions.h
Instance Methods
setActionsTo:overrideExisting:
Method assigns all the actions of another ‘SCCellActions’ class to the current one.
- (void)setActionsTo:(SCCellActions *)actions overrideExisting:(BOOL)override
Parameters
- actions
The source ‘SCCellActions’ class.
- override
Set to TRUE to override any existing actions, otherwise set to FALSE.
Declared In
SCCellActions.h