我在我的一个视图之上添加了一个子视图,并使用 animateWithDuration 对其进行动画处理,使其从屏幕底部开始并在屏幕顶部结束。一切正常,除了animateWithDuration完成后,顶部的视图没有用户交互,而下面的视图仍然有用户交互。如果我删除animateWithDuration,并在其正常位置启动子视图,则用户交互也会按照我的预期工作,这就是为什么我认为animateWithDuration是问题所在。
这是我的代码:
UIViewController *viewController = [[CCouponDetailViewController alloc] init];
[[viewController view] setBounds:CGRectMake(0, ([UIScreen mainScreen].bounds.size.height * -1), viewController.view.bounds.size.width, viewController.view.bounds.size.height)];
[self addChildViewController:viewController];
[self.view addSubview:viewController.view];
CGRect newFrame = viewController.view.frame;
newFrame.origin.x = 0;
newFrame.origin.y = ([UIScreen mainScreen].bounds.size.height * -1);
[UIView animateWithDuration:1.0
animations:^{
viewController.view.frame = newFrame;
}
completion:^(BOOL finished){
[viewController didMoveToParentViewController:self];
}
];
我的另一个问题(不是很重要只是好奇)是在 newFrame 中,我将 y 设置为与我最初设置边界时相同的值,但它会移动。我本来希望 newFrame 要求 ay 值为“0”,但是当我这样做时,什么也没发生。只是想知道为什么会这样。