我正在使用此代码进行UIView过渡效果
[UIView beginAnimations: nil context: nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView commitAnimations];
现在的问题是,当我在Landscape Left中旋转ipad时,它表现得很奇怪,如果我给出条件是否景观是否比UIViewAnimationTransitionCurlDown还要好,那么动画仍然与在Landscape-right方式下的动画不同
答案 0 :(得分:2)
我有完全相同的问题。 对于那些很难理解问题的人:
当你做"蜷缩"在横向模式下,通过右侧的按钮,页面开始从右上角向左下翻转(意思是,您用右手翻动页面,然后向书的左侧移动。也意味着书籍和# 39; s绑定在左边。)
当你做同样的事情时,但是左边的按钮,即使正确旋转内容,动画也不会旋转,说" shouldAutorotateToInterfaceOrientation:True"在vc。因此,动画从左下角到右上角,给人的印象是现在书籍的装订就在右边。
一些代码来说明:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
view1 = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[view1 setBackgroundColor:[UIColor greenColor]];
[view1 setFont:[UIFont systemFontOfSize:80]];
[view1 setText:@"VIEW 1"];
view2 = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[view2 setBackgroundColor:[UIColor redColor]];
[view2 setFont:[UIFont systemFontOfSize:80]];
[view2 setText:@"VIEW 2"];
}
return self;
}
-(void)didSwipeNext
{
[self performSelector:@selector(swipePrevious) withObject:nil afterDelay:1];
}
-(void)didSwipePrevious
{
[self performSelector:@selector(swipeNext) withObject:nil afterDelay:1];
}
-(void)swipeNext
{
[UIView beginAnimations:@"curl" context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationDidStopSelector:@selector(didSwipeNext)];
[view1 removeFromSuperview];
[self.view addSubview:view2];
[UIView commitAnimations];
}
-(void)swipePrevious
{
[UIView beginAnimations:@"curl" context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationDidStopSelector:@selector(didSwipePrevious)];
[view2 removeFromSuperview];
[self.view addSubview:view1];
[UIView commitAnimations];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:view1];
[self performSelector:@selector(swipeNext) withObject:nil afterDelay:1];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
答案 1 :(得分:1)
您是否尝试过使用:
[UIView setAnimationBeginsFromCurrentState:NO];
如果在旋转更改期间启动动画并且该值设置为YES,则在坐标反转时可以使用UIView的帧。
你可以使用方法willAnimateRotationToInterfaceOrientation和didAnimateRotationToInterfaceOrientation在旋转前停止动画,并在之后恢复它。
答案 2 :(得分:0)
Ben G明确地解释了这个问题。我找到了一个解决方法,但不知道潜在的原因。我的解决方法是:UIViewAnimationOptionTransitionCurlUp