You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The onCellUnHighlight function for a Row doesn't get called if the onCellHighlight function is not also specified for the Row. This is confusing because the documentation doesn't state that both of these functions have to be defined for onCellUnHighlight to work.
This is the debug code I used to find this bug.
form +++Section("Debug")<<<TextRow("debugTextRow1"){
$0.title ="Debug Text Row 1"}.onCellHighlight{ cell, row inprint("text onCellHighlight 1")}.onCellUnHighlight{ cell, row inprint("text onCellUnHighlight 1")}<<<TextRow("debugTextRow2"){
$0.title ="Debug Text Row 2"}.onCellUnHighlight{ cell, row inprint("text onCellUnHighlight 2")}
Tapping on debugTextRow1 and then tapping outside debugTextRow1 to trigger onCellUnHighlight works as expected with both onCellHighlight and onCellUnHighlight defined.
However, doing the same steps with debugTextRow2 doesn't work as expected. The onCellUnHighlight function for debugTextRow2 is never called.
I'm using XCode 7.1.1 and the project has a deployment target of iOS 9.1
The text was updated successfully, but these errors were encountered:
@jefflai Actually this is not an issue. This is how onCellHighlight and onCellUnHighlight work by default.
Your custom onCellUnHighlight is not being invoked because each time the cell is highlighted we override onCellUnHighlight as shown below.
publicfinalclassTextRow:_TextRow,RowType{requiredpublicinit(tag:String?){
super.init(tag: tag)onCellHighlight{ cell, row inletcolor= cell.textLabel?.textColor
row.onCellUnHighlight{ cell, _ in
cell.textLabel?.textColor = color
}
cell.textLabel?.textColor = cell.tintColor
}}}
The reason we override by default the onCellUnHighlight from inside onCellHighlight is to put back the original label text color since it can be changed at any time.
So in order to avoid this you must set up a onCellHighlight function in addition to onCellUnHighlight. Your custom onCellHighlight will not override onCellUnHighlight.
The onCellUnHighlight function for a Row doesn't get called if the onCellHighlight function is not also specified for the Row. This is confusing because the documentation doesn't state that both of these functions have to be defined for onCellUnHighlight to work.
This is the debug code I used to find this bug.
Tapping on debugTextRow1 and then tapping outside debugTextRow1 to trigger onCellUnHighlight works as expected with both onCellHighlight and onCellUnHighlight defined.
However, doing the same steps with debugTextRow2 doesn't work as expected. The onCellUnHighlight function for debugTextRow2 is never called.
I'm using XCode 7.1.1 and the project has a deployment target of iOS 9.1
The text was updated successfully, but these errors were encountered: