我有一个正常工作的页面卷曲。问题是 iPad 的旋转。该应用程序仅在横向运行,并支持 l 左和 l 右。如果 iPad 是“横向”,则卷曲应该发生在右下角。如果我旋转 iPad,视图会按预期旋转,但现在当我尝试卷曲发生在左上角时。我添加了一条通知,告诉我它何时旋转并尝试更改动画子类型但没有骰子。
-(IBAction)curlViewUp
{
uiv_help.alpha = 1.0;
[UIView animateWithDuration:1.0
animations:^{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.7];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = @"pageCurl";
animation.subtype = curlDirection;
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.20;
[animation setRemovedOnCompletion:NO];
[self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"];
[self.view addSubview:uiv_help];
;}
];
}
-(IBAction)curlViewDown
{
uiv_help.alpha = 0.0;
[UIView animateWithDuration:1.0
animations:^{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.7];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
animation.type = @"pageUnCurl";
animation.subtype = curlDirection;
animation.fillMode = kCAFillModeForwards;
animation.startProgress = 0.80;
[animation setRemovedOnCompletion:YES];
[self.view.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];
//[self.view removeFromSuperview];
[uiv_help removeFromSuperview];
;}
];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft | interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(void)checkRotation:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if(orientation == UIInterfaceOrientationLandscapeLeft)
{
NSLog(@"UIInterfaceOrientationLandscapeLeft");
curlDirection = @"fromRight";
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"UIInterfaceOrientationLandscapeRight");
curlDirection = @"fromRight";
}
}