求指教关于手指按下松开或者移出到按钮的外部调用stop方法

我写了在Controller中自己定义了一个UIButton,绑定了一个事件UIControlEventTouchUpInside,然后在运行的时候,手指按下不松开,慢慢到按钮外部,按钮的UIControlEventTouchUpInside这个事件不执行。由于需求需要在手指移到按钮外部的时候执行UIControlEventTouchUpInside绑定的事件,所以我又给把这个方法绑定到这个按钮的UIControlEventTouchDragExit上,但这个事件出现了一个很让人郁闷的问题,当移出按钮外后一段距离了, 它才开始执行,请问我想让这个按钮在手指移出或者按下松开执行事件该怎么做?
贴出来写的代码,

_publishBtn = [[UIButton alloc] init];    float publishWith = (self.view.frame.size.width - 205)/2;
    _publishBtn.frame = CGRectMake(publishWith, 344, 205, 47);
    _publishBtn.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"btn.png"]];
    [_publishBtn.titleLabel setTextColor:[UIColor blackColor]];
    [_publishBtn setTitle:@"按住" forState:UIControlStateNormal];
    _publishBtn.titleLabel.shadowColor = [UIColor blackColor];
    _publishBtn.titleLabel.shadowOffset = CGSizeMake(0, 1.0);
    [_publishBtn setTitle:@"松开" forState:UIControlStateHighlighted];
    [_publishBtn setBackgroundImage:[UIImage imageNamed:@"btn_on.png"] forState:UIControlStateHighlighted];
    [_publishBtn addTarget:self action:@selector(stop) forControlEvents:UIControlEventTouchUpInside];
    [_publishBtn addTarget:self action:@selector(stop) forControlEvents:UIControlEventTouchDragExit];
    [_publishBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:_publishBtn];
智慧大石
浏览 103回答 1
1回答

守着一只汪

UIControlEventTouchUpOutside这个在手指松开就执行的,但是移出边界后就不执行的。你是想移出到按钮之外响应这个事件,看看别的event可以不,如果不行,你用个view来替代吧。
打开App,查看更多内容
随时随地看视频慕课网APP