iPhone页面翻页效果

7

我正在使用这段代码实现页面翻页效果...在模拟器和设备上都可以正常工作...但是它并不是苹果文档中记录的API (setType:@"pageCurl"),因此在App Store审核过程中被iPhone开发者计划拒绝了。

animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0.5;
animation.endProgress   = 1;
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"pageCurl"];
[animation setSubtype:@"fromRight"];
[animation setRemovedOnCompletion:NO];
[animation setFillMode: @"extended"];
[animation setRemovedOnCompletion: NO];
[[imageView layer] addAnimation:animation 
                         forKey:@"pageFlipAnimation"]; 

所以我进行了更改,并使用了以下方式。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationWillStartSelector:@selector(transitionWillStart:finished:context:)];
[UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)];
// other animation properties
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp 
                       forView:imageView cache:YES];
// set view properties
[UIView commitAnimations];

在上面的代码中,我想要在页面翻页效果到一半时停止它。但是我不能像iPod上的地图应用程序那样在中途停止它。有没有任何解决方法?或者在iPod touch的页面翻页效果中使用了哪些苹果文档记录的方法?
我已经搜索了很多,但没有得到任何答案。有人可以帮帮我吗?谢谢提前。

你好。所以你使用了@pagecurl类型,但应用被拒绝了? - user281300
如果您想要执行部分卷曲,但保持工具栏静止(如苹果的地图应用程序),请查看我的解决方案此处 - Tim Arnold
4个回答

9

If I may?

SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];

......


4
我找到了一个使用动画块将UIView添加到UIViewController中的解决方案。
m_Container是包含我的视图动画(self)的UIView。 self是一个UIView。
注意:您需要导入QuartzCore。
要使用页面翻页动画呈现视图,您可以使用:
-(void)PresentView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.endProgress = 0.65;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageCurlAnimation"];  
                         [m_container addSubview:self];
                         ;}  
     ];    
}

当您想隐藏此视图时,可以使用以下方法:

-(void)HideHelpView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageUnCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.startProgress = 0.35;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];  
                         [self removeFromSuperview];

                         ;}  
     ];

}

这段代码是错误的。CATransition setTimingFunction: 的参数类型应为 UIViewAnimationCurve 而非 CAMediaTimingFunction。使用 CAMediaTimingFunction functionWithName: 获取定时函数。 - titaniumdecoy

1

必须使用停在中间的翻页效果吗?最简单的方法是用更简单的动画(例如滑出)替换页面翻页,或者只将整个视图卷起来。

您可以尝试通过在运行时构造字符串来欺骗。

[animation setType:[@"page" stringByAppendingString:@"Curl"]];

虽然您仍在使用未记录的方法。


我想知道这是否会被忽略掉...有人有做过这个的经验吗? - coneybeare

0

自3.2版本开始,部分卷曲功能已被官方支持。请查看克里斯的示例代码以获取更多信息。更多细节请参见UIViewController类引用下的常量。


这似乎与地图的功能不同。也就是说,您可以将此转换应用于整个视图,但不能应用于子视图,因此会保留工具栏。 - Jason McCreary

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接