1

I have created custom UIButton and add these methods:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    self.layer.backgroundColor = self.highlightedColor.CGColor;
    [self setTitleColor:self.highlightedTextColor forState:UIControlStateNormal];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    self.layer.backgroundColor = [UIColor clearColor].CGColor;
    [self setTitleColor:self.highlightedColor forState:UIControlStateNormal];
}

I also use storyboard and I have added segue to the custom button and try to push new view controller.

But seems touches methods conflict with my segue and the new controller never appear by pressing custom button. If I remove -touchesBegan and -touchesEnded methods it works good and the new view controller appears.

I don't add any code for trigger segue just use storyboard 'arrows'.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • Have you considered just using target-action? You could set yourself as the target on touchDown, and again on touchUpInside || touchUpOutside || touchesCanceled || etc, and do your highlighting when you receive those callbacks? – cmyr Dec 03 '14 at 18:19
  • @cmyr, yep there are many options how to implement it, e.g. gestures and etc, but seems nor gestures nor touches won't work. I have implement some other solution as for highlight - setBackgroundImage with color and setTitleColor for highlighted text. But in the fact we have the issue I've described and as for logic it should work. I supposed, but it does not. – Matrosov Oleksandr Dec 03 '14 at 18:38
  • 1
    try calling [super touchesBegan]. It may be that your target-action is never firing because you're never properly handling the touch events. – cmyr Dec 03 '14 at 18:46
  • 1
    @cmyr hm cool, I even don't think about firing. Adding super to those method solves this issue thanks! – Matrosov Oleksandr Dec 03 '14 at 19:16

0 Answers0