[TIMOB-11873] iOS: Custom Label in Button stays in highlightedColor state once button is released.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-05-02T22:16:07.000+0000 |
Affected Version/s | Release 2.1.3, Release 2.1.4, Release 3.0.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Matt Bryson |
Assignee | Eric Merriman |
Created | 2012-10-04T15:37:50.000+0000 |
Updated | 2017-05-02T22:16:07.000+0000 |
Description
*Actual result*
Adding a label to a button, with a color and highlightedColor will initially work, and show the highlightedColor on press. But on release it remains in the highlightedColor, and does not revert back to the color. If you press and drag off the button, you can sometimes get the color back.
*Test case*
This is reproducible in the kitchen sink example of custom label button. (Once pressed the label stays green and does not revert back to red).
*Workaround*
It looks like something changed in iOS 6 with the event cycle for the button.
In TiUIButton : - (void)controlAction:(id)sender forEvent:(UIEvent *)event
It sets the highlighted state of child views to button.highlighted.
However, in this controlAction method, button.highlighted appears to always be true, regardless of
the touch.phase. So the label will never be told to to remove its highlighted state.
I fixed this by manually setting the state on child views:
//Manually set highlighted as button.highlighed is always true in ios6 at this point in the event cycle
switch (touch.phase) {
case UITouchPhaseBegan:
if (touchStarted) {
return;
}
touchStarted = YES;
fireEvent = @"touchstart";
[self setHighlighting:true]; //Manually set highlight
break;
case UITouchPhaseMoved:
fireEvent = @"touchmove";
break;
case UITouchPhaseEnded:
touchStarted = NO;
fireEvent = @"touchend";
if (button.highlighted) { //This is always true now so this might need to move?
fireActionEvent = [touch tapCount] < 2 ? @"click" : @"dblclick";
}
[self setHighlighting:false]; //Manually set highlight
break;
case UITouchPhaseCancelled:
touchStarted = NO;
fireEvent = @"touchcancel";
[self setHighlighting:false]; //Manually set highlight
break;
default:
return;
}
// this appears to alwasy set to true, so manually set above
// [self setHighlighting:button.highlighted];
Tested and confirmed the Kitchen Sink issue on iOS 5.1 Ti SDK 2.1.3 GA, 2.1.4 GA and latest 3.0.0 CI. Description mentions a change in iOS 6, but this happens on iOS 5.1 too...
Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.