Questions tagged «uiswipegesturerecognizer»

12
UISwipeGestureRecognizer的设置方向
我想向基于视图的iPhone项目中添加简单的滑动手势识别。应当识别所有方向(右,下,左,上)的手势。 在UISwipeGestureRecognizer的文档中进行了说明: 您可以通过使用按位或操作数指定多个UISwipeGestureRecognizerDirection常量来指定多个方向。默认方向是UISwipeGestureRecognizerDirectionRight。 但是对我来说这是行不通的。对所有四个方向进行“或”运算后,只能识别左右滑动。 - (void)viewDidLoad { UISwipeGestureRecognizer *recognizer; recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp)]; [[self view] addGestureRecognizer:recognizer]; [recognizer release]; [super viewDidLoad]; } -(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer { NSLog(@"Swipe received."); } 我通过在视图中添加四个识别器来解决此问题,但我很想知道为什么它不能像文档中所宣传的那样起作用? - (void)viewDidLoad { UISwipeGestureRecognizer *recognizer; recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [recognizer …


13
如何启用滑动以删除TableView中的单元格?
我有一个UIViewController实现TableViews委托和数据源协议的。现在,我想向单元格添加“滑动删除”手势。 我应该怎么做。 我给出了commitEditingStyle方法的空白实现,并且还将Editing属性设置为YES。 仍然没有滑动功能。 现在我需要分别添加UISwipeGesture到每个单元格吗? 还是我错过了什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.