我在导航栏中有一个 searchButton,点击后会调用以下方法:
- (IBAction)search:(id)sender
{
if (nil == searchViewController)
searchViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
searchViewController.view.backgroundColor = [UIColor clearColor];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:searchViewController.view
cache:NO];
[self.view addSubview:searchViewController.view];
[UIView commitAnimations];
}
它应该加载 SearchViewController.xib,其中包含一个带有 UISearchBar 的 View 和两个按钮。当我第一次调用搜索方法时, View 很快就会出现,并带有一些奇怪的动画,当我再次调用它时,动画就正常了。有谁知道可能出了什么问题吗?
最佳答案
将两个 View 添加到 appdelegate 中的窗口中,我遇到了与您相同的问题,并且这有效。奇怪的是,因为后来我将它们从 super View 中删除,但它仍然有效。
关于iphone - UIView 动画第一次不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2773797/