uitapgesturerecognizer

UITapGestureRecognizer not work when I animate the UIImageView

我只是一个虾纸丫 提交于 2019-12-05 03:32:22
When I want to animate the UIImageView , the UITapGestureRecognizer added to it can not work. WHY??? -(void) testTap:(id)sender { NSLog(@"Test tap..."); } -(void) testSlide { UITapGestureRecognizer* testTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(testTap:)] autorelease]; testTap.numberOfTapsRequired = 2; UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tip_slide"]] autorelease]; [imageView setFrame:CGRectMake(40, 40, 200, 200)]; imageView.userInteractionEnabled = YES; imageView.multipleTouchEnabled = YES; [imageView

detecting finger up/down UITapGestureRecognizer

吃可爱长大的小学妹 提交于 2019-12-05 00:45:00
How can I know when the finger is down and when is it up with UITapGestureRecognizer ? The documentation says I should only handle UIGestureRecognizerStateEnded as tap so it means there is UIGestureRecognizerStateBegin when finger is down, but all I get is UIGestureRecognizerStateEnded . The code I use to register the recognizer is: [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)] UITapGestureRecognizer is a discrete gesture recognizer, and therefore never transitions to the began or changed states. From the UIGestureRecognizer Class Reference: Discrete gestures

Swift: how to make a UIView clickable in UITableViewCell?

老子叫甜甜 提交于 2019-12-04 19:27:20
问题 Inside a UITableViewCell , I am trying to implement a button with both an image and a text . It seems the standard UIButton cannot achieve that. So I created a UIView which contains a UIImageView and a UILabel . You can see the implementation here on the right hand side, the "follow trip" button (the "+" is an UIImageView, and "follow trip" is a UILabel) I am now trying to make such UIView (i.e. the button) clickable, but I cannot find a way. This is my implementation, but it doesn't work:

Single and double taps on UITableViewCell in Swift 3

依然范特西╮ 提交于 2019-12-04 19:15:49
I have storyboard segue on TableViewCell, which I use for transfering to another VC on cell click in didSelectRowAt method. Now I made double tap TapGestureRecognizer to handle touble tap on cell. Problem is that on single tap, segue is performing and double tap is not working. Double tap works fine with clicking out of cell. Is possible to solve this somehow with my code so far? Or I need to delete segue and handle single tap and double tap separately. Thanks for any suggestions override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from

How to set up a tap gesture only for specific ranges of a UILabel in Swift 3

假如想象 提交于 2019-12-04 16:32:24
I have an attributed string set to UILabel with multiple underlines , colors like below image and I know How to setup a tap gesture for whole label (with enabling user interaction ) and below is my code for what I have done including setting up underline and setting up font colors for multiple ranges . import UIKit class ViewController: UIViewController { @IBOutlet weak var mylabel: UILabel! var theString = "I have agree with the terms and conditions and privacy policy" override func viewDidLoad() { super.viewDidLoad() mylabel.text = theString let tap = UITapGestureRecognizer(target: self,

iOS - Add Tap Gesture to UITextField

一笑奈何 提交于 2019-12-04 11:31:08
I have problem with add a Tap Gesture to my UITextField. Below code: @IBAction func hanldeTap(recognizer: UITapGestureRecognizer) { println("works") } This action is associated with Tap Gesture Recognizer. In my TextField I have defined gestureRecognizer in OutletCollections . In my guess it should works. In described configuration gesture works e.x. for button or custom view. Can you tell my what could go wrong and how can I fix this? UITextField has delegate methods , you might want to consider implementing those. Or just add action event to your textfield. For example in viewDidLoad

Add a click event to some text in ios NSString

无人久伴 提交于 2019-12-04 09:40:30
I have the following code and want to make parts of my text be clickable and call another UIViewController (not a website). NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"testing it out @clickhere"]; NSInteger length = str.length; [str addAttribute:NSForegroundColorAttributeName value:[UIColor bestTextColor] range:NSMakeRange(0,length)]; The NSMutableAttributedString gets set to a UILabel like so: label.attributedText = str; Whats the best way to do this? I can't seem to find a great answer. An example of what I want is suppose I have a UILabel like so

MpMovieplayerController tap gesture recognizer doesn't trigger when in fullscreen

99封情书 提交于 2019-12-04 09:13:41
I´m trying to use UITapGestureRecognizer in order to handle the taps on my fullscreen video. If I omit [self.player setFullscreen:YES animated:NO]; it works, but then my video won't scale to fit the screen. From my .m: - (void)viewDidLoad { [super viewDidLoad]; NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mov"]; player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:videoPath]]; player.shouldAutoplay = NO; player.view.frame = self.view.bounds; player.scalingMode = MPMovieScalingModeAspectFit; player.controlStyle =

UIPageViewController Traps All UITapGestureRecognizer Events

∥☆過路亽.° 提交于 2019-12-04 08:37:46
It's been a long day at the keyboard so I'm reaching out :-) I have a UIPageViewController in a typical implementation that basically follows Apple's standard template. I am trying to add an overlay that will allow the user to do things like touch a button to jump to certain pages or dismiss the view controller to go to another part of the app. My problem is that the UIPageViewController is trapping all events from my overlay subview and I am struggling to find a workable solution. Here's some code to help the example... In viewDidLoad // Page creation, pageViewController creation etc.... self

UITapGestureRecognizer working on UIImageView but not on UILabel

最后都变了- 提交于 2019-12-04 05:10:34
问题 I have a UITableViewCell class named CommentsTableViewCell which among other things includes a UIImageView and a UILabel . Code I'm using: let tapGesture = UITapGestureRecognizer(target: self, action: #selector(CommentsTableViewCell.showUserViewController)) nameLabel.userInteractionEnabled = true avatarRoundImageView.userInteractionEnabled = true nameLabel.addGestureRecognizer(tapGesture) avatarRoundImageView.addGestureRecognizer(tapGesture) As you can understand I have a function which shows