Tag: uigesturerecognizer

UILabel UILongPressGestureRecognizer不工作?

如何获得UILongPressGestureRecognizer上的UILongPressGestureRecognizer当我实现下面的代码,它不会调用该函数。 那么请告诉我我做了什么错事? UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LabelLongPressed:)]; longPress.minimumPressDuration = 0.5; // Seconds longPress.numberOfTapsRequired = 0; [objlblDuplicate addGestureRecognizer:longPress]; [longPress release];

即使没有实施,uilongpressgesturerecognizer也会崩溃

我尝试了每一个可能的search,但在一个星期内我没有发现任何类似的东西 我正在制作一个显示表格视图的应用程序。 可以使用单元类中的UIPanGestureRecognizer拖动单元(由自定义类和Interface Builder创build)。 一切正常,除了当我保持手指按在单元格上的应用程序崩溃的错误: -[UILongPressGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x94670a0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILongPressGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x94670a0' 我知道它是什么意思(通常是一个错误的参数发送到实例),但我真的不知道这是如何可能的,因为我的代码中没有UILongPressGestureRecognizer跟踪。 我试图截取LongPressGestureREcognizer EVERYWHERE(在单元格类,在tableview的类,在分配每个单元格之前),但错误仍然是相同的(我看了很多主题在这里的主题和相信我,语法是正确的。 如果你想要任何其他文件随意问(这是我在这里的第一篇文章,我不知道我必须显示)。 谢谢你的宝贵帮助。 好吧,问题仍然有麻烦:我设法设置一个断点并打印堆栈跟踪,这里是: 0 uBellow 0x0000ac57 -[OpinionCell gestureRecognizerShouldBegin:] + 71 1 UIKit 0x00914939 -[UIGestureRecognizer _shouldBegin] + 1334 2 UIKit 0x0091181a -[UIGestureRecognizer setState:] […]

如何在UIView中优先考虑手势识别器和触摸

从阅读UIGestureRecognizer类参考意味着API将为您处理触摸和手势控制的优先级,确保您的touchesBegan和相关方法不会在视图上调用,除非手势识别器首先失败: 窗口在将触摸事件传送到附加到手势识别器的命中testing视图之前将其传送给手势识别器。 通常,如果手势识别器分析多点触摸序列中的触摸stream并且不识别其手势,则该视图接收全部的触摸。 如果手势识别器识别其手势,则视图的其余触摸被取消。 我已经添加了一个轻扫手势,我的看法,它正在工作。 通过一些日志logging,当我做一个单一的滑动,方法报告。 然而,我的touchesBegan方法也是通过它的日志报告,尽pipetouchesCancelled方法,正如所料,也收到一条消息。 我想,并期望,手势识别,以防止touchesBegan或touchesMoved被调用。 所以我的问题是:对于手势识别器实际上是延迟触摸基于其状态,是否有额外的设置必要? 文件没有提出任何其他必要的。 我的设置很简单: swipeUpTwoFinger=[[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doubleSwipeUp:)]autorelease]; swipeUpTwoFinger.direction=UISwipeGestureRecognizerDirectionUp; swipeUpTwoFinger.numberOfTouchesRequired=2; [self addGestureRecognizer:swipeUpTwoFinger]; 我也尝试过这个testing,以确保识别器在用touchesBegan处理之前失败(如果您相信文档上述内容,则不需要此testing),但touchesBegan在此testing之后仍在处理日志行: if (swipeUpTwoFinger.state==UIGestureRecognizerStateFailed)

iOS:UIScrollView检测滑动手势

我有一个UIScrollView通过使用一个定时器,每3秒滚动到下一页(types的幻灯片)自动滚动。 现在我想实现一个检测任何用户交互的函数,只要用户与scrollview交互,就立即取消计时器,这样他就可以自己滚动滚动视图。 什么是最好的方法来做到这一点? ScrollView不是子类,正在使用UIScrollViewDelegate。 会很高兴的一些提示。 干杯。

类似Snapchat的文字在图像上

我一直在试图在图像上实现类似Snapchat的编辑文本。 我到目前为止所做的是在UIImageView的中心实现一个UILabel,并且向这个UILabel添加了3个手势:UIPanGestureRecognizer,UIPinchGestureRecognizer和UIRotationGestureRecognizer。 我已经设法实现了泛方法,但我很难让Pinch + Rotation像他们一样stream畅,我得到了可怕的结果T_T 你们觉得这是怎么产生的? 哪些组件参与了这个&如果你有任何阅读/观看的材料,我可以用来完成这一点。 谢谢 :) 编辑: 这些是我执行处理捏和旋转的方法: func handlePinch(recognizer: UIPinchGestureRecognizer) { if let view = recognizer.view as? UILabel { view.transform = CGAffineTransformScale(view.transform, recognizer.scale, recognizer.scale) } } func handleRotate(recognizer: UIRotationGestureRecognizer) { if let view = recognizer.view as? UILabel { view.transform = CGAffineTransformRotate(view.transform, recognizer.rotation) } } 预览video,了解我如何实施这项工作: https : //drive.google.com/file/d/0B-AVM51jxsvUY2RUUHdWbGo5QlU/view?usp=sharing

在UILongPressGestureRecognizer上,我该如何检测哪个对象生成事件?

我有几个UIButtons的观点。 我用UILongPressGestureRecognizer成功实现了以下select器; – (void)longPress:(UILongPressGestureRecognizer*)gesture { if ( gesture.state == UIGestureRecognizerStateEnded ) { NSLog(@"Long Press"); } } 在这个方法中我需要知道的是UIButton收到的是longpress,因为我需要做一些不同的事情,具体取决于哪个button收到longpress。 希望答案不是将longpress发生的位置坐标映射到button边界的某个问题 – 宁可不去那里。 有什么build议么? 谢谢!

使用UIScreenEdgePanGestureRecognizer而不移动MKMapView

我有一个包含MKMapView的UIViewController(事实上,它包含一个包含MKMapView的全屏容器,但不应该有任何影响) 我实现了一个UIScreenEdgePanGestureRecognizer(显示一个抽屉),如下所示: self.swipeRight = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleEdgeGesture:)]; [self.swipeRight setEdges:UIRectEdgeLeft]; [self.swipeRight setDelegate:self]; [self.view addGestureRecognizer:self.swipeRight]; 并使其工作,我不得不添加以下方法(返回YES): (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer; 但是随着抽屉的出现,地图正在移动! 我试过所有的技巧,以防止它,但无法…(我试过shouldBeRequiredToFailByGestureRecognizer或requireGestureRecognizerToFail例如) 任何想法如何我可以防止MapView的移动,当手势是从LeftEdge ScreenEdgePan?

iPhone的iOS如何使UIRotationGestureRecognizer和UIPinchGestureRecognizer一起工作来缩放和旋转UIView子视图?

我在我的应用程序中实现了拖放/resize/旋转标签。 到目前为止,除了UIRotationGestureRecognizer手势之外,一切正在工作。 更具体地说,它不适用于UIPinchGestureRecognizer手势。 通常这两个手势竞争两个手指触摸,所以我正在并行运行它们。 以下是手势识别器调用的两种方法。 当做旋转手势时, 视图围绕它的中心旋转 ,高度和宽度变化如下:高度变成宽度,宽度变成高度。 最终,视图消失。 在视图中,我有另一个自动resize的视图。 通常,捏手势也会自动调整子视图的大小,但在这种情况下,自动调整遮罩的子视图消失。 子视图有高度和宽度的弹簧和左/顶撑杆。 我究竟做错了什么? 我怎样才能调整和扩大手势UIView? 所有委托方法和连接都正确设置。 我需要了解如何处理识别器应用缩放和旋转的顺序。 //makes 2 gesture recognizers behave together – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; } – (IBAction)handleRotationFrom:(id)sender { NSLog(@"Gesture rotation %.1f", rotationGestureRecognizer.rotation); //attempt to continuously rotate the label, starting with a remembered rotation float rotation = atan2(activeCompanionLabelView.transform.b, activeCompanionLabelView.transform.a); NSLog(@"existing rotation […]

点击UISlider设置值

我创build了一个Slider(作为video的控件操作,就像YouTube一样),并设置最大(持续时间)和最小值。 然后使用SeekToTime更改当前时间。 现在,用户可以滑动滑块的拇指来改变该值 我想要实现的是让用户点击滑块上的任何位置并设置video的当前时间。 我从这个答案得到了一个方法,我试图将其应用到我的案件,但无法使其工作 class ViewController: UIViewController, PlayerDelegate { var slider: UISlider! override func viewDidLoad() { super.viewDidLoad() // Setup the slider } func sliderTapped(gestureRecognizer: UIGestureRecognizer) { // print("A") let pointTapped: CGPoint = gestureRecognizer.locationInView(self.view) let positionOfSlider: CGPoint = slider.frame.origin let widthOfSlider: CGFloat = slider.frame.size.width let newValue = ((pointTapped.x – positionOfSlider.x) * CGFloat(slider.maximumValue) / widthOfSlider) slider.setValue(Float(newValue), […]

UIPanGestureRecognizer在触摸时立即执行某些操作

我是新来的ios,所以我提前道歉,如果我失去了一些明显的东西。 我正在创造一个谜题,我希望单个拼图在触摸时增加尺寸,减less放手。 目前我有: -(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer{ if(recognizer.state == UIGestureRecognizerStateBegan) else if(recognizer.state == UIGestureRecognizerStateEnded) } 当盘子开始时(这也是开始的时候),拼图块增加了尺寸,当盘子结束时(如所期望的),拼图块的尺寸减小。 我希望一旦用户触摸了这个棋子,拼图块移动之前,尺寸就会增加。 当select一个瓷砖时,这在Words With Friends中看到。 我努力了 -(IBAction)handleTap:(UITapGestureRecognizer *)recognizer{ if(recognizer.state == UIGestureRecognizerStateBegan) else if(recognizer.state == UIGestureRecognizerStateEnded) } 这只会在手指抬起之后才会增加拼图。 我的问题: 有一种方法可以在手指碰到拼图块后增加拼图的尺寸,然后继续平移手势。 先谢谢你。