Rae*_*ime 7 objective-c gesture ios uitapgesturerecognizer
我有一个子类UIView,并添加了touchesBegan和touchesEnd方法......
在touchesBegan,我backgroundColor通过使用self.backgroundColor = [UIColor greenColor]... 将白色设置为绿色,touchesEnd我将颜色重置为白色.
它工作但很慢.通过点击视图,它需要0.5 - 1.0秒,直到我看到绿色.
选择一个单元格UITableView的速度要快得多.
尝试这个:
self.view.userInteractionEnabled = YES;
UILongPressGestureRecognizer *recognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(doCallMethod:)];
recognizer.delegate = self;
recognizer.minimumPressDuration = 0.0;
[self.view addGestureRecognizer:recognizer];
- (void)doCallMethod:(UILongPressGestureRecognizer*)sender {
if(sender.state == UIGestureRecognizerStateBegan){
NSLog(@"Begin");
self.view.backgroundColor = [UIColor greenColor];
}else if (sender.state == UIGestureRecognizerStateEnded){
NSLog(@"End");
self.view.backgroundColor = [UIColor whiteColor];
}
}
Run Code Online (Sandbox Code Playgroud)
注意: 它会工作得更快。
| 归档时间: |
|
| 查看次数: |
1538 次 |
| 最近记录: |