【发布时间】:2015-01-30 08:05:23
【问题描述】:
通过以下代码,我将在按钮单击时显示一个带有动画的视图。
UIViewController *modalView = self.pageViewController;
[self.view addSubview:modalView.view];
[UIView animateWithDuration:1 animations:^{
CGRect currentRect = modalView.view.frame;
currentRect.origin.y = 650.0f;
currentRect.size.height = 295.0f;
[modalView.view setFrame:currentRect];
[modalView.view removeFromSuperview];
}];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
这适用于第一次单击按钮。当我一次又一次地按下按钮时,这不再是动画了。它只是第一次制作动画。有什么办法吗?
提前致谢!
【问题讨论】:
-
这真的不是办法。您不应该将另一个 viewcontrollers 视图作为子视图添加到另一个 viewcontroller,它会破坏 mvc 模式。转而深入研究 UIViewControllerTransisitions,这是一个很好的教程:teehanlax.com/blog/custom-uiviewcontroller-transitions
标签: ios objective-c animation uiview