UITapGestureRecognizer not working on iOS9

前端 未结 4 1099
再見小時候
再見小時候 2020-12-21 03:08

I have an application which uses UITapGestureRecognizers which seem to not work in iOS9 Beta 2.

They are successfully calling

- (BOOL)g         


        
相关标签:
4条回答
  • 2020-12-21 03:16

    Implementing all optional delegate of UIGestureRecognizer will work.

    0 讨论(0)
  • 2020-12-21 03:22

    I ran into this problem as well, specifically when trying to get both my buttons and views w/ tap gestures within a table cell to respond to a click whose layout was defined in a xib. Worked fine on iOS 8 & 10, but not 9. The actual problem was that I added those to a custom uiview and assigned the view's class to my UITableViewCell subclass, rather than use a Table View Cell object within IB. Thus I did not add my subviews to the contentView that the IB object gives you, causing me the problem. The fix was to redo the xib to use the Table View Cell as my root, so I could attach my subviews to the Content View.

    0 讨论(0)
  • 2020-12-21 03:28

    It seems that iOS9 looks for a <pressTypeMask key="allowedPressTypes"/> line in the xml of the gesture recognizer and the tap recognizer doesn't work without it. To fix you can either build your recognizers in code, add that line into the xml or delete and re-add the gesture recognizer in Xcode 7, which will properly add the pressTypeMask into the xml.

    I wonder if apple will fix iOS9 to work without that line in the XML, but for now, this is an easy fix.

    0 讨论(0)
  • 2020-12-21 03:35

    I checked it via Xcode-7 beta 2

    I've created vc with gesturerecognizer and create outlets for property and action. in viewDidload setted delegate, like this: enter image description here

    All methods, that was called during debug - i've marked //called

    I received events to the next methods:

    func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
        print("worked")
        // called
        return true
    }
    
     func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
     {
        //called
        print("worked")
        return true
    }
    
    
     func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOfGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
     {
        print("worked")
        //called
        return true
    }
    

    Try recreate project as i mentioned and check all your outlets and delegate

    Hope this helps

    0 讨论(0)
提交回复
热议问题