【问题标题】:Iphone page curl effectiphone翻页效果
【发布时间】:2010-03-27 14:17:47
【问题描述】:

我正在将此代码用于 Page curl 效果 ....它在模拟器和设备中工作正常...但它不是 (setType:@"pageCurl") 苹果记录的 api ,这导致它被 iPhone 拒绝App Store审核过程中的开发者计划:

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 中的页面卷曲效果?

我正在寻找很多。但没有得到任何答案?谁能帮我? 在此先感谢..plz

【问题讨论】:

  • 你好。所以你确实使用了@pagecurl 类型并且应用被拒绝了?
  • 如果您想进行部分卷曲,但要保持工具栏静止,就像在 Apple 的地图应用中一样,请查看我的解决方案 here

标签: iphone


【解决方案1】:

如果可以的话?

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

......

【讨论】:

    【解决方案2】:

    我找到了使用动画块将 UIView 添加到 UIViewController 的解决方案。

    m_Container 是一个包含我的视图动画(自我)的 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: 获取定时函数。
    【解决方案3】:

    必须使用中点停止卷曲效果吗?最简单的方法是用更简单的动画(例如滑出)替换 page curl,或者只是将整个视图向上卷曲。

    您可以尝试通过在运行时构造字符串来作弊,例如

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

    尽管您仍在使用未记录的方法。

    【讨论】:

    • 我想知道这是否会从裂缝中溜走……有人有这样做的经验吗?
    【解决方案4】:

    从 SDK 3.2 开始正式支持部分卷曲。检查 Chris 的示例代码。更多信息可以在常量下的 UIViewController 类参考中找到。

    【讨论】:

    • 这似乎与地图的功能不同。也就是说,您可以将此过渡应用于整个视图,但不能应用于子视图,因此会离开工具栏。
    猜你喜欢
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多