FullScreenAnimations icon indicating copy to clipboard operation
FullScreenAnimations copied to clipboard

Open book animation only plays sporadically on iOS 6

Open jgale opened this issue 12 years ago • 9 comments

When run on a device, sometimes it displays, sometimes it doesn't. It always seems to display in the simulator.

I don't know that I've ever seen it actually work on iPad on an actual device.

jgale avatar Oct 03 '12 21:10 jgale

The animation works perfectly fine in iOS 6, (both in simulator and on device) you must be observing another issue? Have you got it sorted as of yet?

alexsaidani avatar Oct 20 '12 02:10 alexsaidani

For me, it works very reliably in the simulator but only occasionally on the device on iOS 6. I don't think I've ever seen it on the iPad, I see it on my iPhone only very occasionally. Do you see it 100% reliably on your device?

jgale avatar Oct 21 '12 20:10 jgale

Yeah I can see it 100% of the time on both iPhone and iPad iOS 5-6 (simulator too), although it is very difficult to implement into an app upon opening. Are you getting this simply when running the sample project?

alexsaidani avatar Oct 21 '12 21:10 alexsaidani

Thanks for the tip! You are right, my demo project works 100% of the time but it's very sporadic when integrated into my real app. At least that gives me something to look into.

jgale avatar Oct 22 '12 00:10 jgale

How are you going about implementing it into your app?

alexsaidani avatar Oct 22 '12 01:10 alexsaidani

Okay I found a much better way of doing this that is 10 times simpler. Stick the following code in your app delegate - didFinishLaunchingWithOptions

    //1. add the image to the front of the view...
        UIImageView *splashImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
        [splashImage setImage: [UIImage imageNamed:@"Default"]];
        [self.window.rootViewController.view addSubview:splashImage];
        [self.window.rootViewController.view bringSubviewToFront:splashImage];

        //2. set an anchor point on the image view so it opens from the left
        splashImage.layer.anchorPoint = CGPointMake(0, 0.5);

        //reset the image view frame
        splashImage.frame = CGRectMake(0, -20, 320, 480);

        //3. animate the open
        [UIView animateWithDuration:1.5
                              delay:0.0
                            options:(UIViewAnimationCurveEaseOut)
                         animations:^{

                             splashImage.layer.transform = CATransform3DRotate(CATransform3DIdentity, -M_PI_2, 0, 1, 0);
                         } completion:^(BOOL finished){

                             //remove that imageview from the view
                             [splashImage removeFromSuperview];
                         }];

alexsaidani avatar Oct 22 '12 02:10 alexsaidani

You can then use the following to adjust for iPhone 5 screen size. A bit fragmented but it works perfectly.

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { CGSize result = [[UIScreen mainScreen] bounds].size; if(result.height == 480) { // iPhone Classic } if(result.height == 568) { // iPhone 5 } }

alexsaidani avatar Oct 22 '12 02:10 alexsaidani

Interesting, your approach is a lot cleaner. It has a few problems that makes it not work for me though:

  • Most importantly, it doesn't work with iPad, because I need to be able to check self.interfaceOrientation to decide what image to load. I can't think of any other way to check what orientation we are in when in didFinishLaunchingWithOptions. Any ideas?
  • It's missing the perspective aspects of the 3D transform, but that's easy to add in
  • The setting of -20 on the frame messed it up on mine, I needed mine to be at 0,0. Maybe this depends on your status bar settings in your app.
  • Also, you might want to be careful with checking for if height == 480 or 568, since those are CGFloats and checking equality that way is risky.

jgale avatar Oct 22 '12 03:10 jgale

However, after playing around with this I realized why the animation wasn't working on my own real app.

I was using an animation duration of 0.5, and it just wouldn't show up often. Switching it to use a duration of 1.0 seemed to make it long enough that it actually showed up on my app.

jgale avatar Oct 22 '12 03:10 jgale