uitapgesturerecognizer

Tap Gesture on animating UIView not working

若如初见. 提交于 2019-11-29 11:39:07
I have a tap gesture on a UILabel who's translation is being animated. Whenever you tap on the label during the animation there's no response from the tap gesture. Here's my code: label.addGestureRecognizer(tapGesture) label.userInteractionEnabled = true label.transform = CGAffineTransformMakeTranslation(0, 0) UIView.animateWithDuration(12, delay: 0, options: UIViewAnimationOptions.AllowUserInteraction, animations: { () -> Void in label.transform = CGAffineTransformMakeTranslation(0, 900) }, completion: nil) Gesture code: func setUpRecognizers() { tapGesture = UITapGestureRecognizer(target:

Issue with a UITapGestureRecognizer

心不动则不痛 提交于 2019-11-29 10:24:51
I have a main viewController, it is called WelcomeViewController . I have a UIView subclass and that has some view related stuff in it. I want to add a UITapGestureRecognizer to that subclass. I only want the gesture recognizer to acknowledge taps inside that subview. How do I do that. Should I put the UITapGestureRecognizer in the subclass or should I put it in the Welcome vc. Thanks in advance. Also, I have played around with it a bunch and can't seem to figure it out. It depends on whether you want to handle the tap in your custom view object or in the view controller. If in the view, add

iOS: TapGestureRecognizer Issues

感情迁移 提交于 2019-11-29 08:53:15
So I have an app that behaves like a photo gallery and I'm implementing the ability for the user to delete the images. Here is the setup: I have 9 UIImageViews, imageView, imageView2, etc. I also have an "Edit" button, and a tapGesture action method. I dragged a Tap Gesture Recognizer over onto my view in IB, and attached it to each one of the UIImageViews. I also attached the tapGesture action method to each of the UIImageViews. Ideally, I would like the method to only become active when the "Edit" button is pressed. When the user taps Edit, then taps on the picture they want to delete, I

pass parameter to UITapGestureRecognizer [duplicate]

强颜欢笑 提交于 2019-11-29 07:03:36
This question already has an answer here: Pass a NSDictionary as parameter to UITapGestureRecognizer 3 answers i have created dynamic UIimage view and and UITapGestureRecognizer to the view its look like this UIImageView *image = [[UIImageView alloc ] initWithFrame:CGRectMake(x, 0, 200, 150)]; NSString *ImageURL = [str objectForKey:@"imageLink"]; NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]]; image.image = [UIImage imageWithData:imageData]; UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)]

UITapGestureRecognizer on a UIButton

时光总嘲笑我的痴心妄想 提交于 2019-11-29 05:03:01
I have a UIButton which has an IBAction as well as a UITapGestureRecognizer to detect double taps. At the moment it looks like the IBAction is blocking the recognizer. Is there a way to stop this or do UITapGestureRecognizer even work on buttons? If so wouldn't it be better to just add the recognizers and remove the IBActions? EDIT UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget : self action : @selector (handleDoubleTap:)]; [doubleTap setNumberOfTapsRequired:2]; [A1 addGestureRecognizer:doubleTap]; [A2 addGestureRecognizer:doubleTap]; [B1

How to detect a tap gesture in subviews

独自空忆成欢 提交于 2019-11-28 23:27:23
Quick question: how do i detect if a tap gesture recognizer is within a subview of the view it is added to? Eg. if i click on an object such as a square that has been added as a subview to a background which a tap gesture recognizer has been added to, how do I detect that it has been tapped? Brandon A You can grab the point of the tap off the gesture recognizer when your handler method is called respective to any view you wish using -locationInView: . Then, use the following method on UIView: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event to get a reference to the actual sub

Detect touch event on UIScrollView AND on UIView's components [which is placed inside UIScrollView]

主宰稳场 提交于 2019-11-28 19:40:33
I have UIViewController on my simple storyboard IPad project which contains UIScrollView which is placed over entire surface (1024 x 768). I have created 3 XIB files which are UIViews which my application loads on start in viewDidLoad and add them into UIScrollView. Each of these 3 XIB files contains only one UIButton. This is hierarchy: ~ UIViewController ( UIViewControllerClass is class for this UIViewController) ~~ UIScrollView (contains 3 identical UIViews) ~~~ UIView ( UIViewClass is File's Owner for this XIB file) ~~~~ UIButton I would like that my UIViewControllerClass becomes aware of

Problems with gesture recognizer in iOS 7

梦想的初衷 提交于 2019-11-28 16:14:12
I'm adding several UIView objects (e.g. 5) to the screen, one inside the other. This, for example, view5.superview = view4 , view4.superview = view3 , view3.superview=view2 , view2.superview = view1 . For all these UIView I set uitapgesturerecognizer; for view1-4 I just do NSLog(@"tap %@", self) in callback, while for view5 tap I set the following: delete view4 from the hierarchy, then put the same object view4' at the same place of the hierarchy. This object also contains view5' for which UITapGestureRecognizer is set (practically, I replace one part of markup with similar one). Then I start

Click Event on UIImageView programmatically in ios

别等时光非礼了梦想. 提交于 2019-11-28 15:56:36
I am displaying a image from code here is the code UIImageView *preArrowImage =[[UIImageView alloc]init ]; preArrowImage.image =[UIImage imageNamed:@"arrowprev.png"]; preArrowImage.frame = CGRectMake(20, 60, 10, 30); [self.view addSubview:preArrowImage]; I want to handle the touch event on the preArrowImage programmatically. Objective-c UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)]; singleTap.numberOfTapsRequired = 1; [preArrowImage setUserInteractionEnabled:YES]; [preArrowImage addGestureRecognizer:singleTap]; -(void

Unrecognized selector sent to instance Swift 3

匆匆过客 提交于 2019-11-28 11:39:28
I want to implement TapGestureRecognizer with the selector , below is the code where I added tapGestureRecognizer to my imageView let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:))) firstImageView.isUserInteractionEnabled = true firstImageView.tag = 1 firstImageView.addGestureRecognizer(tapFirstGestureRecognizer) Here is the action method func assignImage(_ sender: UIImageView){ imagePicker.allowsEditing = false imagePicker.sourceType = .photoLibrary imageViewTag = sender.tag present(imagePicker, animated: true, completion: nil) } Compiler