开发者

UIWindow stops receiving touches after removing a subview from it

I'm using a subclass of UIWindow to handle touch event in all views of the app. I'm trying to implement a drag and drop mechanism.

When tapping and holding on a view, i remove that view and start dragging with the finger. problem is after i remove the view the window stop receiving touch events until i lift my finger and touch it again.

help?

EDIT: i found that aft开发者_Go百科er the subview is removed, the window is receiving touches but the touch phase is UITouchPhaseStationary and not UITouchPhaseMoved, even though there is only one UITouch in [event touches]; how is this possible?


I am not quite sure, but I think your problem is because your are trying to handle events in UIWindow class, rather than UIViewController class. UIWindow is not designed to do so. Why don't you try this:

  1. Add an instance of UIViewController class to your project.
  2. Add the view of that UIViewController to your UIWindow instance.
  3. Add the touch handling method to the UIViewController.
  4. Add your first view to UIViewController.
  5. Respond to touch event.
  6. Remove the first view from UIViewController, and bring in the second view, or whatever. (It is kind of swapping views under the UIViewController, rather than in the instance of UIWindow.)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜