0

我写了一个简单的演示来展示我的问题。按钮需要添加两个触摸事件:拖动和触摸。

UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(300, 100, 100, 100);
btn1.backgroundColor = [UIColor redColor];
[btn1 addTarget:self action:@selector(stretchBtnDragMoving:withEvent:) forControlEvents:UIControlEventTouchDragInside];
[btn1 addTarget:self action:@selector(stretchBtnDragEnded:withEvent:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
[self.view addSubview:btn1];

接着,

- (void)stretchBtnDragMoving:(UIControl *)control withEvent:(UIEvent *)event
{
    NSLog(@"moving");
}
- (void)stretchBtnDragEnded:(UIControl *)control withEvent:(UIEvent *)event
{
    NSLog(@"end or in");
}

当我像平常一样在 iPhone6s/6s plus 中触摸按钮时,这两种方法都会被调用。
但是当我轻触按钮时,只调用了第二种方法。
当我使用iPhone6/6 plus、iPad等设备时,无论我如何触摸按钮,都只调用了第二种方法。

4

0 回答 0