-1

At some point in my app, a user can move a UIView after a long press on that view. This works fine.

When the view passes over a specific region, the app has to switch to another UIViewController. The moving view is attached to this new controller. So far so good.

The problem is that now the moving view is not moving anymore (i.e. it doesn't follow the finger of the user) :-(

Seems this issue is related to the UILongPressGestureRecognizer that was fired in a ViewController that is not active anymore.

Any idea how I could handle that ?

Viral Savaj
  • 3,379
  • 1
  • 26
  • 39
Patrock
  • 33
  • 5

2 Answers2

0

You should implement touchesBegan, touchesEnded etc to handle moving of your view. This way, when you're switching the controller, you can still move that view.

Anyway, this idea seems to be weird at least and I'd reconsider app architecture on your place.

Nat
  • 12,032
  • 9
  • 56
  • 103
  • Yes, I totaly understand that this implementation might seem realy weird and ugly but it actualy fits perfectly the purpose of the app. The only issue is this "freeze". Shortcuting the gestureRecognizer and using touches might be a good idea. Will make some tests and keep you posted. Thx. – Patrock May 20 '15 at 22:11
0

ofcourse there might be a requirment to use a UIPanGesturerechognizer, why dont you enable or add it to the parent view on long press?

Naresh Reddy M
  • 1,096
  • 1
  • 10
  • 27
  • You mean adding a UIPanGestureRecognizer to the view AFTER switching to the new UIViewController? Sounds like a good idea but I need this PanGesture to be activated already (i.e. being in the Began state). Possible ----> Began ----> [Changed] ----> Ended. Is it possible to do that? – Patrock May 21 '15 at 10:18
  • When you add a pan gesture rechognizer for a view,you can get the scale property from the pan gesture rechognizer instance,so now what you need to do is you should set the uivew object's center to your scale value,so as said earlier you can get the sacle in your target method,you should check wether ur scale position is matching with ur desired area to move to next view controller or something,when it matches you just write some code to move and adding to new view,otherwise just leave the user to play around the screen with the UIView Object :) Hope It will Helps HTH!coding is really fun :) – Naresh Reddy M May 21 '15 at 10:41
  • i actually dont have a mac with me now,im just trying to give you an idea about the working functionality of your desired feature. – Naresh Reddy M May 21 '15 at 10:42
  • Works fine with the added PanGesture. Thx :-) – Patrock May 26 '15 at 21:58