1

I have a image view inside a scroll view and I add a tap recognise to the image view and it work but when i scroll it will transform the image view and the tap recogniser is gone .

         // Avatar -----------

        let avatarScaleFactor = (min(offset_HeaderStop, offset)) / userImage.bounds.height / 1.4 // Slow down the animation
        let avatarSizeVariation = ((userImage.bounds.height * (1.0 + avatarScaleFactor)) - userImage.bounds.height) / 2.0
        avatarTransform = CATransform3DTranslate(avatarTransform, 0, avatarSizeVariation, 0)
        avatarTransform = CATransform3DScale(avatarTransform, 1.0 - avatarScaleFactor, 1.0 - avatarScaleFactor, 0)

1 Answers1

0

If you are adding imagesView in scrollView using for loop i.e programmatically,then add gesture for every imageView and then test.Hope it will work.

  • I have a view inside got a scroll view i am adding a image view on top of the scroll view . How i am suppose to do –  Apr 01 '16 at 13:05
  • Are you adding only one imageView?,please elaborate hierarchy. – Akshay Hastekar Apr 01 '16 at 13:20
  • i found the problem but i dont know how to fixed it when the user scroll i make the image view CAtranform using which make it smaller if i delete this line everything works fine . Here the transform code in the question –  Apr 01 '16 at 13:31
  • It seems like CAtransform reset the gesture recognizer on the image view , how can i fixed this ? –  Apr 01 '16 at 13:37
  • First of all I can not say much without seeing code,but there is a option if gesture is reset.Use scrollView's delegate method which gets called after scrolling finished and then check for gesture on imageView if reset then add again.Make property of ImageView globally so you can access in scrollView's delegate method. – Akshay Hastekar Apr 01 '16 at 13:44
  • how can check the gesture on imageview? –  Apr 01 '16 at 13:59
  • One thing,if you are sure that gesture is reset as scroll the image on scrollView then no need to check if imageView responds to gesture or not,just addGesture to imageView [imageview1 setUserInteractionEnabled:YES] [imageview1 addGestureRecognizer:singleTap]; – Akshay Hastekar Apr 01 '16 at 14:08
  • also you can refer this link http://stackoverflow.com/questions/19218080/tap-gesture-not-recognized-on-uiimageview ,hope it will help you. – Akshay Hastekar Apr 01 '16 at 14:10
  • I found the code that causing the trouble avatarTransform = CATransform3DTranslate(avatarTransform, 0, avatarSizeVariation, 0) –  Apr 02 '16 at 03:14