【问题标题】:touchesEnded not getting called when combined with UIButton?touchesEnded 与 UIButton 结合时没有被调用?
【发布时间】:2013-05-09 15:18:40
【问题描述】:

我已经实现,当我的UIButton 突出显示并且我的UISwipeGestureRecognizer 识别到手势时,它将开始一个动画。问题是我想在选择UIButton 并做出手势后调用touchesEnded 时结束动画。但是,如果我在此过程中点击UIButton,则永远不会调用touchesEnded

其余时间它可以工作,但如果我不能在动画期间使用它,它对我来说毫无用处。这是我所做的:

-(IBAction) swipeDown:(UISwipeGestureRecognizer *)recognizer
{
     if(onebutton.highlighted)
     {
          //Animate
     }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    for(UITouch *touch in touches)
    { 
        if(touch.phase == UITouchPhaseEnded)
        { 
            NSLog(@"touched");
        } 
    } 
}

有什么想法吗?

【问题讨论】:

    标签: iphone uibutton touches uianimation uiswipegesturerecognizer


    【解决方案1】:

    您可以为按钮添加另一个在释放时触发的操作,而不是 touchesEnded。

    [button addTarget:self action:@selector(buttonTapEnded) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      相关资源
      最近更新 更多