uitapgesturerecognizer

Handling Multiple GestureRecognizers

点点圈 提交于 2019-12-04 04:10:12
I've run into an issue understanding UIGestureRecognizers . My goal right now is to have a set of GestureRecognizers to do different tasks, for example: override func viewDidLoad() { mainScene = GameScene(size: self.view.bounds.size) main = view as! SKView mainScene.panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(shiftView(recognizer:))) main.addGestureRecognizer(mainScene.panRecognizer) mainScene.tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(testTap(recognizer:))) main.addGestureRecognizer(mainScene.tapRecognizer) mainScene.pinchRecognizer =

Swift: how to make a UIView clickable in UITableViewCell?

非 Y 不嫁゛ 提交于 2019-12-03 11:54:00
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: class StationsIntroHeader: UITableViewCell { @IBOutlet weak var bigButton: UIView! override func

Tap on UISlider to Set the Value

折月煮酒 提交于 2019-12-03 11:15:20
问题 I created a Slider (operating as control of the video, like YouTube has at the bottom) and set the maximum (duration) and minimum values. And then used SeekToTime to change the currentTime. Now, the user can slide the thumb of the slider to change the value What I want to achieve is letting the user tap on anywhere on the slider and set the current time of the video. I got an approach from this answer, and I tried to apply it to my case, but couldn't make it work class ViewController:

Add a tap gesture to a part of a UILabel

狂风中的少年 提交于 2019-12-03 11:03:57
问题 I have a NSAttributedString like so: 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; How do I make a tap gesture (or something clickable) to another viewcontroller for the words '@clickhere in the

How can I add a UITapGestureRecognizer to a UILabel inside a table view cell?

独自空忆成欢 提交于 2019-12-03 08:27:00
问题 I am using a NIB file to layout a custom table view cell. This cell has a label with outlet called lblName. Adding a UITapGestureRecognizer to this label never fires the associated event. I have userInteractionEnabled = YES. I'm guessing that the problem is that the UILabel is in a TableView and that the table/cell view is intercepting the taps. Can I do something about this? All I want to do is perform some custom action when a UILabel is pressed! All of the solutions for doing this that I

can't click UIButton inside a cell in UITableview

三世轮回 提交于 2019-12-03 06:52:16
searched already some possible fixes but all did not solve mine. i keep clicking the cell in the uitableview rather than the buttons inside it. here is my code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.backgroundColor = [UIColor blackColor]; UIView *v = nil; NSArray *array

Add a tap gesture to a part of a UILabel

99封情书 提交于 2019-12-03 00:32:11
I have a NSAttributedString like so: 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; How do I make a tap gesture (or something clickable) to another viewcontroller for the words '@clickhere in the string above? Thanks! I think, the best way is adding the UIGestureRecognizer to your UILabel and validate

How to detect double-taps on cells in a UICollectionView

两盒软妹~` 提交于 2019-12-02 15:13:14
I want to respond to double-taps on cells in a UICollectionView, and have a double-tap action cancel cell selection. This is what I've tried: UITapGestureRecognizer *tapRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; tapRecogniser.numberOfTapsRequired = 2; for (UITapGestureRecognizer *recogniser in [self.collectionView gestureRecognizers]) { [recogniser requireGestureRecognizerToFail:tapRecogniser]; } [self.collectionView addGestureRecognizer:tapRecogniser]; That is, I am trying to get the default gesture recognisers to fail if my double

Tap gesture is not working in imageView but it working another view

泪湿孤枕 提交于 2019-12-02 13:26:57
问题 i have working in image and video overlay in that i put one image view, i assigned the tapGestureRecognizer to that image view its not working,For video i put one MPMoviePlayerController and i set the tapGestureRecognizer to it this one working fine but the image view only not working.Below is my code - (void)viewDidLoad { [super viewDidLoad]; videoimg=[[UIImageView alloc]init];//OvelayImage videoimg.image=[UIImage imageNamed:@"fb.png"]; videoimg.userInteractionEnabled=YES; videoimg

Can we Add Tap Gesture to UILabel?

只愿长相守 提交于 2019-12-02 13:24:49
I have added Label in the UIView and created its outlet, then with the help of UITapGestureRecognizer i have added the functionality,but when i tap or click in the label. Label text does not changes. I searched for the similar question and i got the answer also its what I've written but still the label text is not changing. Code written in Swift 3.0. Here's the code i have written - import UIKit class testingViewController: UIViewController { @IBOutlet weak var testLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: