uitapgesturerecognizer

Tap Gesture on part of UILabel

余生颓废 提交于 2019-11-28 11:29:21
I could successfully add tap gestures to a part of UITextView with the following code: UITextPosition *pos = textView.endOfDocument;// textView ~ UITextView for (int i=0;i<words*2-1;i++){// *2 since UITextGranularityWord considers a whitespace to be a word UITextPosition *pos2 = [textView.tokenizer positionFromPosition:pos toBoundary:UITextGranularityWord inDirection:UITextLayoutDirectionLeft]; UITextRange *range = [textView textRangeFromPosition:pos toPosition:pos2]; CGRect resultFrame = [textView firstRectForRange:(UITextRange *)range ]; UIView* tapViewOnText = [[UIView alloc] initWithFrame

tap gesture not recognized on uiimageview

可紊 提交于 2019-11-28 06:47:44
I added two uiimageview s, one on another subview uiview ( imageview1,imageview2 ). In the first view the top uiimageview is hidden( imageview2 ) and in the second view the bottom imageview is hidden( imageview1 ). Allocating tap gesture: UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneTap:)]; UITapGestureRecognizer *singleTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneTap:)]; Set user interaction for both uiimageview to YES. [singleTap setNumberOfTapsRequired:1]; [singleTap1 setNumberOfTapsRequired:1];

Tap Gesture on animating UIView not working

拟墨画扇 提交于 2019-11-28 05:25:32
问题 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) },

Issue with a UITapGestureRecognizer

本秂侑毒 提交于 2019-11-28 03:39:48
问题 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. 回答1: It depends on

AVPlayer UITapGestureRecognizer not working

删除回忆录丶 提交于 2019-11-28 03:25:09
问题 I have this code for my AVPlayerViewController . UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvPlayer)]; [self.avPlayerViewController.view addGestureRecognizer:tap]; but this is not working.. :S, I tried setting [self.avPlayerViewController.view setUserInteractionEnabled:YES]; still no good.. The only working solution is to use UIGestureRecognizer and implement it's shouldReceiveTouch delegate and check if the av player is touched.. but

iOS How to dismiss UIAlertView with one tap anywhere?

强颜欢笑 提交于 2019-11-27 23:02:32
I want to dismiss UIAlertView anywhere outside it with one tap. I want to show a UIAlertView without any button. I have standard UIAlertView codes here, but I need input how to dismiss it, if it is possible. With UITouch? With UITapGestureRecognizer? Thank you. EDIT: in viewDidLoad alertview initialization here with name "alert" if (alert) { emptyview = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,480)]; emptyview.backgroundColor = [UIColor clearColor]; [self.view addSubview:emptyview]; [emptyview addSubview:alert]; NSLog (@"emptyview is there!"); UITapGestureRecognizer *singleTap = [

Button tap and long press gesture

江枫思渺然 提交于 2019-11-27 19:46:59
I'm having a little trouble with the gestures. I'm trying to use both tap and long press on the same button, so I've used @IBAction func xxx (sender: UITapGestureRecognizer) and @IBAction func xxx (sender: UILongPressGestureRecognizer) but my button seems to react to both functions when I tap. What might be wrong? func long(longpress: UIGestureRecognizer){ if(longpress.state == UIGestureRecognizerState.Ended){ homeScoreBool = !homeScoreBool }else if(longpress.state == UIGestureRecognizerState.Began){ print("began") } } Hard to say what´s not working with your code, with the only two rows that

UITapGestureRecognizer on a UIButton

不羁的心 提交于 2019-11-27 18:51:16
问题 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

How to enable “tap and slide” in a UISlider?

陌路散爱 提交于 2019-11-27 15:28:05
What I want to get is a UISlider which lets the user not only slide when he starts on its thumbRect , but also when he taps elsewhere. When the user taps on the slider but outside of the thumbRect , the slider should jump to that value and then still keeping up to the user's sliding gesture . What I have tried so far was implementing a subclass of UIGestureRecognizer like in this suggestion . It starts right then when a touch down somewhere outside the thumbRect occurs. The problem is that the slider sets its value but then further sliding gestures are ignored because the touch down recognizer

iOS 7.1 UITapGesture not working with UIPickerView

廉价感情. 提交于 2019-11-27 13:27:53
We are using a UIPickerView to allow a user to select from a list of options. We are adding UIPickerView as a subview of a container UIView. We are then adding a UITapGestureRecognizer to the container UIView . The UITapGestureRecognizer is being used to dismiss the picker via removing it's super view. In iOS 7.0 and previous versions, this was working as expected. However, in iOS 7.1 this set up is no longer working in the sense that UITapGestureRecognizer is not recognizing the tap and calling the selector specified in the action (dismissing the picker view and container view). code is below