开发者

How can I make OpenFlow work correctly in iOS 5.0?

开发者 https://www.devze.com 2023-04-11 04:54 出处:网络
I recently updated my application to use the iOS 5.0 SDK. 开发者_JAVA技巧 Within it, I am using Alex Fajowski\'s OpenFlow cover flow implementation.

I recently updated my application to use the iOS 5.0 SDK. 开发者_JAVA技巧 Within it, I am using Alex Fajowski's OpenFlow cover flow implementation.

I found that when I run the application on iOS 5.0, OpenFlow is making an incorrect transformation or Z repositioning when I swipe through images.

Is there something I can do to make OpenFlow work correctly on the iOS 5.0 SDK?


I made an improvement over what you have here and it certainly makes it work smoothly (the way it used to be in iOS 4).

In AfOpenFlowView.m, instead of what you stated above (in -setUpInitialState):

leftTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION / 2.0);
leftTransform = CATransform3DRotate(leftTransform, SIDE_COVER_ANGLE, 0.0f, 1.0f, 0.0f);
rightTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION / 2.0);
rightTransform = CATransform3DRotate(rightTransform, SIDE_COVER_ANGLE, 0.0f, -1.0f, 0.0f);

Inside -layoutCover:selectedCover:animated, place the following code:

CGFloat newZPosition = SIDE_COVER_ZPOSITION / 2.0;

CABasicAnimation *zPositionAnimation = [CABasicAnimation animationWithKeyPath:@"zPosition"];
[zPositionAnimation setToValue:[NSNumber numberWithFloat:newZPosition]];
[zPositionAnimation setDuration:(animated ? .3 : 0.0)];
[zPositionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[zPositionAnimation setRemovedOnCompletion:NO];
[zPositionAnimation setFillMode:kCAFillModeForwards];

Now, instead of doing:

aCover.layer.zPosition = newZPosition;

Replace it with:

[aCover.layer addAnimation:zPositionAnimation forKey:nil];

You can conditionally enable either depending on whether it's running on iOS 4 or 5.

Best,


Today, I finally found the solution for this issue. Apparently, in iOS 5, zPosition is not being animated anymore (too bad, cause the documentation does say so). This is why, this bug may be fixed, by including the correct transition into the CATransform3D.

Earlier:

    leftTransform = CATransform3DIdentity;
    leftTransform = CATransform3DRotate(leftTransform, SIDE_COVER_ANGLE, 0.0f, 1.0f, 0.0f);
    rightTransform = CATransform3DIdentity;
    rightTransform = CATransform3DRotate(rightTransform, SIDE_COVER_ANGLE, 0.0f, -1.0f, 0.0f);

Now it looks like this:

    leftTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION);
    leftTransform = CATransform3DRotate(leftTransform, SIDE_COVER_ANGLE, 0.0f, 1.0f, 0.0f);
    rightTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION);
    rightTransform = CATransform3DRotate(rightTransform, SIDE_COVER_ANGLE, 0.0f, -1.0f, 0.0f);

Hope it helps you guys, as it did help me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号