uitapgesturerecognizer

How can I detect taps on a particular part (substring) of a UILabel?

人盡茶涼 提交于 2020-01-12 04:52:09
问题 I am new to iOS development. I dont know whether this questions has been asked already or not, I tried searching for the solution on stackoverflow but didn't get any results. Question : I have a UILabel called myLabel with the text: "Click here to proceed" Now the problem is I want to perform an action when user taps only "Click". I know how to use UITapGestureRecognizer , but it responds to the whole UILabel . Is it possible to just detect when user taps only on string "Click"? 回答1: You

iOS swift UIImageView change image in tableView cell

Deadly 提交于 2020-01-11 04:19:06
问题 I have a strange problem in tableView Custom cell . for like Image action I write these code in Custom cell called FeedViewCell : self.like.isUserInteractionEnabled = true let CommenttapGestureRecognizer = UITapGestureRecognizer(target:self, action:#selector(likehandleTap)) self.like.addGestureRecognizer(CommenttapGestureRecognizer) func likehandleTap(_ sender: UITapGestureRecognizer) { if self.like.image == UIImage(named: "like-btn-inactive") { self.like.image = UIImage(named: "like-btn

iOS: Adding UITapGestureRecognizer to container view intercepts UICollectionView's didSelectItemAtIndexPath method

亡梦爱人 提交于 2020-01-10 19:27:09
问题 I added a UITapGestureRecognizer to my main Content View in my ViewController to dismiss my keyboard when the content view is tapped. The problem is that I have a UICollectionView inside my content view, and setting the UITapGestureRecognizer intercepts the taps of my UICollectionView . How do I allow my UICollectionView 's taps to go through so that the didSelectItemAtIndexPath method will fire again? func setupGestureRecognizer() { let dismissKeyboardTap = UITapGestureRecognizer(target:

iOS 7.1 UITapGesture not working with UIPickerView

孤者浪人 提交于 2020-01-09 04:47:29
问题 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

How can I set programmatically from code the size of uiimageview to cover full screen in my swift app?

大憨熊 提交于 2020-01-06 18:00:32
问题 This is actually a follow up to this question - How can I display image on fullscreen when user taps on my UIImage in Swift? I managed to add a tap listener to my uiimageview, but now I would like to expand it when user clicks it. I have an iboutlet for that photo: @IBOutlet weak var requestPhoto: UIImageView! and then the listener so far prints this string: func tapHandler(sender: UITapGestureRecognizer) { if sender.state == .Ended { print("photo tapped") } } Now instead of printing the

UITextview: Place focus on becomefirstresponder

不羁岁月 提交于 2020-01-05 12:13:27
问题 I have a UITextView which becomes first responder by tapping. The code looks like this. UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editTextRecognizerTabbed:)]; recognizer.delegate = self; recognizer.numberOfTapsRequired = 1; [self.textViewNotes addGestureRecognizer:recognizer]; - (void) editTextRecognizerTabbed:(UITapGestureRecognizer *) aRecognizer; { self.textViewNotes.dataDetectorTypes = UIDataDetectorTypeNone; self

UITapGestureRecognizer not working for specific [UIView] array

孤街浪徒 提交于 2020-01-05 04:24:10
问题 I have the following piece of code. It's a third party library for a menu (named CarbonKit). When I try to select a specific segment (tab) and add a gesture recognizer, it doesn't work. Any ideas what I'm doing wrong? To be clear, I placed a breakpoint in the handleTap, it it doesn't even enter the function. override func viewDidLoad() { super.viewDidLoad() self.view.userInteractionEnabled = true let tgr : UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector

iOS using UITapGestureRecognizer with UILabel to swipe to the next page

柔情痞子 提交于 2020-01-03 05:10:09
问题 Sorry if I overlooked a potential answer to my question, but I'm having trouble with using the UITapGestureRecognizer with a UILabel inside a subview UIViewController class... Basically, I've created a custom UIViewController that has a UILabel and a few other irrelevant elements. This custom UIViewController, however, is inside a custom UIScrollView with paging enabled and the labels are offset just enough so you can see the next UIViewController's label. What I want to do is when the user

iPhone iOS how to add a UILongPressGestureRecognizer and UITapGestureRecognizer to the same control and prevent conflict?

天涯浪子 提交于 2019-12-31 09:21:52
问题 I'm building an iPhone app that would let the user rearrange some of the UI elements on the screen. How can I add a tap gesture recognizer and a long press gesture recognizer to the same UIView? When I lift up the finger from the long press, the tap gesture recognizer fires. How can I temporarily disable the tap gesture recognizer or prevent it from firing when the user is performing a long press? Thank you! 回答1: To allow both gestures to work together, implement the following delegate method

How to detect double-taps on cells in a UICollectionView

一笑奈何 提交于 2019-12-31 08:08:36
问题 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