我在导航栏的左侧有一个“过滤器”按钮。点击它我想要翻转动画,翻转延迟1.5秒,同时切换到下一个视图。如何添加代码?
我正在使用此导航代码:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
现在我希望按钮上的视图切换时间为1.5秒。我尝试了一些代码,但它没有给我想要的结果。
答案 0 :(得分:1)
试试这个
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:vc animated:YES];
[UIView commitAnimations];
[vc release];
取自How to do the flip animation between two UIViewControllers while clicking info button?
其他方式:
MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[super pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
我是从How to change the Push and Pop animations in a navigation based app
得到的答案 1 :(得分:0)
使用它来延迟推送动画:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self performSelector:@selector(callViewController:) withObject:vc afterDelay:1.5];
-(void)callViewController:(FilterViewController*)vc{
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
}