Tag: uigesturerecognizer

MPMoviePlayerController的视图不能识别触摸

这是我的代码: _mediaPlayer = [[MPMoviePlayerController alloc] init]; _mediaPlayer.controlStyle = MPMovieControlStyleNone; _mediaPlayer.shouldAutoplay = NO; [_mediaPlayer.view setFrame: CGRectMake(5, 5, 600,400)]; [playerHolder addSubview: _mediaPlayer.view]; // [self prepareScreenContentToPlay]; // UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleRollTap:)]; singleFingerTap.numberOfTapsRequired = 1; [_mediaPlayer.view addGestureRecognizer:singleFingerTap]; [singleFingerTap release]; 和手势识别器的动作方法: -(void)handleRollTap:(UITapGestureRecognizer*)sender{ NSLog(@"%@", @"touch"); } MPMoviePlayerController工作正常。 另外我想处理MPMoviePlayerController视图上的触摸,但handleRollTap从不调用。 为什么MPMoviePlayerController的视图不适用于UITapGestureRecognizer? 好。 如果singleFingerTap.numberOfTapsRequired = 2; 那么所有的工作也很好。 但没有一个单一的水龙头..

在iOS 7手势识别器的问题

我添加了几个UIView对象(例如5)到屏幕上,一个在另一个里面。 这个例如view5.superview = view4 , view4.superview = view3 , view3.superview=view2 , view2.superview = view1 。 对于所有这些UIView我设置uitapgesturerecognizer; 对于view1-4,我只是在callback中做NSLog(@“tap%@”,self),而对于view5,我设置了以下内容:从层次结构中删除view4,然后把相同的对象view4'放在层次结构的相同位置。 这个对象还包含view5', UITapGestureRecognizer设置UITapGestureRecognizer (实际上,我用相似的一个replace标记的一部分)。 然后我开始点击view5。 有些时候,view5一直在捕捉它的抽头,一切正常,但随后的抽头数(每当这个数字不同时),其中一个view1-4对象开始捕捉这个抽头,尽pipe我们仍然在点击view5。 整个问题具有随机性 – 有时发生在第十次发射,有时发生在第二次发射。 有时候错误的物体会在第一次敲击时开始捕捉水龙头。 当我遇到一切错误的时候,我也不知道什么东西会碰到水龙头。 视图(n + 1)的帧被设置为例如帧视图(n)的一半,而视图1的帧 – 例如(0,0 320,460)。 上述所有使用UI对象的操作都是在主线程中进行的,而且我所讲的所有关于iOS 4.3 – 6.1的工作都有很多复杂的例子。 但是iOS7使它成为某种随机的地狱。 更新:我创build了一个示例项目,以简化debugging过程。 点击不添加/删除子视图操作。 在屏幕上只有4个视图,点击应用程序logging点击的视图。 所以,你需要挖掘最小的观点(4)。 如果在日志中看到“点击4点击4点击4点…” – 这是一切正常的情况下,停止和再次运行,停止和再次运行,停止和再次运行等等。在一些运行(也许10 +成功的运行)你不会在第一行看到“点击4”,你会看到“点击1”或“点击2”或“点击3”,它会继续 – 这是坏的情况。 示例项目可以从这里下载: http : //tech.octopod.com/test/BuggySample.zip (在档案中只有33 Kb)。 更新2 […]

UISwipeGestureRecognizer抛出无法识别的select器发送错误

我在iOS应用程序中遇到unrecognized selector sent错误。 我试着根据其他类似的线程中提到的答案解决问题,但失败了。 请看下面的代码,并帮助我。 谢谢 class ThirdViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector(("HandleSwipes:"))) let rightSwipe = UISwipeGestureRecognizer(target: self, action: Selector(("HandleSwipes:"))) leftSwipe.direction = .left rightSwipe.direction = .right view.addGestureRecognizer(leftSwipe) view.addGestureRecognizer(rightSwipe) } func HandleSwipes(sender: UISwipeGestureRecognizer) { //if(sender.direction == .left) //{ […]

NSUndoManager使用旋转手势来撤销UIImage旋转

如何使用NSUndoManager旋转UIImageView使用旋转手势? 这是我的代码轮换。 – (void)handleRotate:(UIRotationGestureRecognizer *)recognizer { if (recognizer.state == UIGestureRecognizerStateBegan) { prevRotation = 0.0; } float thisRotate = recognizer.rotation – prevRotation; prevRotation = recognizer.rotation; recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, thisRotate); CGPoint lastpoint = point; }

如何在UISlider中启用“点击并滑动”?

我想得到的是一个UISlider ,它可以让用户不仅在thumbRect开始时滑动,还可以在别处滑动。 当用户轻击滑块但在thumbRect之外时,滑块应该跳到该值,然后仍然保持用户的滑动手势 。 到目前为止我所尝试的是像这个build议一样实现UIGestureRecognizer的子类。 当thumbRect出现在某个地方时,它会立即启动。 问题在于滑块设置了它的值, 但是由于触击识别器已经失去了触摸,所以进一步的滑动手势被忽略 。 我怎样才能实现一个滑块,你可以点击任何地方,但仍然滑动? 编辑:ali59a是如此善良,以添加我现在做的事情的一个例子 。 这需要再次举起手指,之后,我可以触摸并拖动滑动(一个水龙头不是我想要的,我需要一个“触摸和滑动”马上)。

UITableViewCell上的UILongPressGestureRecognizer – 双重调用

我在单元格中使用UILongPressGestureRecognizer。 我需要的是:当用户点击一个单元格1.0秒,调用一个视图控制器。 如果用户点击该单元,则另一个VC。 我可以通过使用UILongPressGestureRecognizer来完成。 但问题是,调用viewController两次。 码: if (indexPath.section == 0 && indexPath.row == 1){ UILongPressGestureRecognizer *longPressTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(memberListWithSearchOptions)]; longPressTap.minimumPressDuration = 1.0; [cell addGestureRecognizer:longPressTap]; [longPressTap release]; } 我认为我需要的是在识别LongPress之后,禁用识别器,直到tableView再次出现在屏幕上。 我怎样才能做到这一点? 谢谢, RL

UITapGestureRecognizer以编程方式触发我的视图中的一个水龙头

编辑:更新,使问题更加明显 编辑2:提出更准确的问题,我的现实世界的问题。 我实际上是希望采取行动,如果他们点击任何地方,除了在屏幕上的文本字段。 因此,我不能简单地听取文本框内的事件,我需要知道他们是否在视图中的任何地方点击。 我正在编写unit testing来断言当手势识别器在我的视图的特定坐标中识别出一个水龙头时会采取某个动作。 我想知道是否可以通过编程方式创build将由UITapGestureRecognizer处理的触摸(在特定坐标处)。 我试图在unit testing中模拟用户交互。 UITapGestureRecognizer是在Interface Builder中configuration的 //MYUIViewControllerSubclass.m -(IBAction)viewTapped:(UITapGestureRecognizer*)gesture { CGPoint tapPoint = [gesture locationInView:self.view]; if (!CGRectContainsPoint(self.textField, tapPoint)) { // Do stuff if they tapped anywhere outside the text field } } //MYUIViewControllerSubclassTests.m //What I'm trying to accomplish in my unit test: -(void)testThatTappingInNoteworthyAreaTriggersStuff { // Create fake gesture recognizer and ViewController […]

如何从UIGestureRecognizer获取UITouch位置

我想从UIGestureRecognizer获取UITouch的位置,但我无法弄清楚如何从文档和其他SO问题中查找。 你们能引导我吗? – (void)handleTap:(UITapGestureRecognizer *)tapRecognizer { CCLOG(@"Single tap"); UITouch *locationOfTap = tapRecognizer; //This doesn't work CGPoint touchLocation = [_tileMap convertTouchToNodeSpace:locationOfTap]; //convertTouchToNodeSpace requires UITouch [_cat moveToward:touchLocation]; } 固定代码在这里 – 这也是固定反转Y轴 CGPoint touchLocation = [[CCDirector sharedDirector] convertToGL:[self convertToNodeSpace:[tapRecognizer locationInView:[[CCDirector sharedDirector] openGLView]]]];

使用UIPinchGestureRecognizer以单向方式缩放uiviews

我想知道我们如何使用UIPinchGestureRecognizer来单独在单个(x或y)方向上扩展UIView 。 例如,如果用户只在一个方向上(水平)移动他的两个手指,则只有该视图的宽度应该增大/减小,并且如果手指仅仅垂直移动,则高度应该改变。 如果手指沿对angular线移动,则uview的高度和宽度应增加/减小。 我已经看到了来自苹果的MoveMe示例代码。 UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scalePiece:)]; [pinchGesture setDelegate:self]; [piece addGestureRecognizer:pinchGesture]; [pinchGesture release]; 比例尺: – (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer { UIView *piece = (UIView *) [gestureRecognizer view]; NSLog(@"scalePiece enter"); if ([gestureRecognizer state] == UIGestureRecognizerStateBegan){ NSLog(@"inside if"); lastTouchPosition = [gestureRecognizer locationInView:piece]; } else if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged){ […]

Swift 3:无法识别的select器发送到实例Xcode 8

我已经编程创build了一个UIView并添加了UIPanGestureRecognizer : class ViewController: UIViewController{ var preludeView: UIView! override func viewDidLoad() { super.viewDidLoad() initViews() createConstrants() let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: Selector(("handleTap:"))) preludeView.addGestureRecognizer(panGestureRecognizer) } func handleTap(recognizer: UIPanGestureRecognizer) { print("WORKING!!!!") } func initViews() { … } func createConstrants() { … } } 但是当我触摸视图Xcode是抛出一个错误: 2016-07-13 09:24:29.918 Draft_Hypa_02 [661:83024] – [Draft_Hypa_02.ViewController handleTap:]:无法识别的select器发送到实例0x17d94a10 2016-07-13 09:24:29.921 Draft_Hypa_02 [661:83024] *终止应用程序由于未捕获的exception'NSInvalidArgumentException',原因是: ' […]