简体   繁体   中英

iOS Animating Container Views makes them not respond to touch events

I have a storyboard with one viewcontroller. This viewcontroller holds 2 container views.

I want these two to change position with each other using a standard animation. After the animation is done the views dont respond to touch events. They behave like static images and are completely unresponsive.

I have tried using this:

    UIView animateWithDuration: animations: completion:
    UIView transitionWithView: duration: options: animations: completion:

I have properties to the childViewControllers

@property (nonatomic, strong) FirstViewController *fVC;
@property (nonatomic, strong) SecondViewController *sVC;

Assigning these using:

self.fVC = self.childViewControllers[0];
self.sVC = self.childViewControllers[1];

Animating:

self.fVC.view
self.sVC.view

---- ----

在此处输入图片说明

Without code it's hard to tell what you're doing wrong, but I'm pretty sure that the problem is that the views (after animating) are now out of their superview's bounds. The child view controller's views are subviews of their respective container views, and by having them switch places, each view is now outside the bounds of its superview. You should be animating the position of the two container views, not the views of the children.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM