uitapgesturerecognizer

How to add function-call (not hyperlink) to part of an NSAttributedString in a UILabel?

允我心安 提交于 2019-12-10 11:39:53
问题 I need to add some tapGestures to some part of a text, thats in a UILabel. It seems to be able to make a hyperlink - so I guess its possible to make a functioncall as well, but I'm just not sure how to do it. Heres my code: let regularFont = UIFont(name: Constants.robotoRegular, size: 13)! let att1 = [NSFontAttributeName: regularFont] let turqoiseFont = UIFont(name: Constants.robotoBold, size: 13)! let att2 = [NSFontAttributeName: turqoiseFont] let attString1 = NSMutableAttributedString

tableView is hiding due to a gestureRecognizer before it can execute didSelectRowAtIndexPath

倾然丶 夕夏残阳落幕 提交于 2019-12-10 11:37:11
问题 I am trying to handle tableViewCell's being tapped, but the problem is that this is a "temporary tableView". I have it coded so that it will appear while the user is editing a UITextField, but then I set up a gesture recognizer to set the tableview to hidden as soon as the user clicks somewhere away from the UITextField. I have the gesture recognizer set up as follows: UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; [tap

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

给你一囗甜甜゛ 提交于 2019-12-09 19:27:47
问题 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

Can we Add Tap Gesture to UILabel?

 ̄綄美尐妖づ 提交于 2019-12-09 03:58:50
问题 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

touchesBegan with delay

梦想的初衷 提交于 2019-12-08 20:08:48
问题 I have a subclass of UIView , and added the touchesBegan and touchesEnd methods... In touchesBegan , I set the backgroundColor from white to green by using self.backgroundColor = [UIColor greenColor] ... in the touchesEnd I reset the color to white. It works but very slowly. By tapping the view, it takes 0.5 - 1.0 sec until I see the green color. Selecting a cell in a UITableView it's much faster. 回答1: Try this: self.view.userInteractionEnabled = YES; UILongPressGestureRecognizer *recognizer

Tap gesture on multiple imageview inside scrollview not firing event , only first imageview tap gesture working?

混江龙づ霸主 提交于 2019-12-08 12:41:40
问题 Scenario is I have imageview which I have added inside a scrollview and then tapgesture added on each imageview but only first one imageview firing event . Have tried following : 1. Created Extension of imageview extension UIImageView { public func openMenu() { let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:Selector("handleTapGesture:")) //mImg.addGestureRecognizer() self.addGestureRecognizer(tapGestureRecognizer) print("open") } } 2. Added tap gesture in the loop (the

Losing tap recognition after adding a UIScrollView under a UIButton

落爺英雄遲暮 提交于 2019-12-08 12:22:52
问题 I have two adjacent UIScrollViews, both partially covered by a UIButton with a tap gesture recognizer. They are added to the view in this order: Scrollview #1 Button Scrollview #2 (added by user interaction) Both scrollviews are z-positioned "behind" the button, but the button does not receive taps where it overlaps with the newer scrollview. Is there a way I can declare "keep this button the topmost receiver of taps"? EDIT: Below is a mockup of the views. The red part of the button is the

collectionView didn't call didSelectItemAtIndexPath when superview has gesture

∥☆過路亽.° 提交于 2019-12-08 04:15:56
问题 collectionView didn't call didSelectItemAtIndexPath when superview has tapGesture。is why? why it print "doGesture" according to the Responder Chain? initCollectionView then add to self.view addTapGesture in self.view click item in iPhone. not call didSelectItemAtIndexPath. - (void)viewDidLoad { [super viewDidLoad]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; self.collectionView = [[MyCollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen

Ios Swift Override double tap of UItextField

大兔子大兔子 提交于 2019-12-08 00:25:28
I want to write a custom code on double tap on UITextField and block the default text editing and popup of the keyboard. I've tried the following and nothing has worked for me so far. Kindly help me solve this problem. let gestureArray = NamTxtBoxVal.gestureRecognizers var tapGesture = UITapGestureRecognizer() for idxVar in gestureArray! { if let tapVar = idxVar as? UITapGestureRecognizer { if tapVar.numberOfTapsRequired == 2 { tapGesture = tapVar NamTxtBoxVal.removeGestureRecognizer(tapGesture) } } } let doubleTap = UITapGestureRecognizer(target: self, action: #selector(namFnc(_:))) doubleTap

how to add double tap gesture to UITextView

一世执手 提交于 2019-12-07 07:30:36
问题 currently I want to let UITextView to have a double tap gesture. It seems UITableView has its own double tap gesture, when we double tapped, some text will be selected. So I want to remove this default double tap gesture to my own gesture recognizer. I tried many methods, and all failed. It seems there's no way to remove the default recognizer of UITextView. I also want to add a transparent view on this UITextView to do double tap event, but this subview will block other gestures on