开发者

Instead of animation white screen is coming

In my app I am displaying animation by splitting .gif file into frames (to show animated splash) by writing this code in newAppDelegate.m

But when I run my app instead of animation white screen is coming and after 5 sec delay application starts.

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Array to hold jpg images
    imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];

    // Build array of images, cycling through image names

    imageArray = [NSMutableArray arrayWithObjects: [UIImage imageNamed:@"f1.jpg"], [UIImage imageNamed:@"f2.jpg"], [UIImage imageNamed:@"f3.jpg"], [UIImage imageNamed:@"f4.jpg"], [UIImage imageNamed:@"f5.jpg"], [UIImage imageNamed:@"f6.jpg"], nil];
    NSLog(@"total image:%d", imageArray.count);

    // Animated images - centered on screen
    animatedImages = [[UIImageView alloc] 
                      initWithFrame:CGRectMake(
                                               (SCREEN_WIDTH / 2) - (IMAGE_WIDTH / 2), 
                                               (SCREEN_HEIGHT / 2) - (IMAGE_HEIGHT / 2) + STATUS_BAR_HEIGHT,
                                               IMAGE_WIDTH, IMAGE_HEIGHT)];
    animatedImages.animationImages = [NSArray arrayWithArray:imageArray];

    // One cycle through all the images takes 1.5 seconds
    animatedImages.animationDuration =1;

    // Repeat forever
    animatedImages.animationRepeatCount = -1;开发者_高级运维

    // Add subview and make window visible
    [window addSubview:animatedImages];
    [window setBackgroundColor:[UIColor blackColor]];
    [window makeKeyAndVisible];

    // Start it up
    [animatedImages startAnimating];

    // Wait 5 seconds, then stop animation
    [self performSelector:@selector(stopAnimation) withObject:nil afterDelay:5.0];

}

- (void)stopAnimation
{
    [animatedImages stopAnimating];
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}


I think the problem is

animatedImages.animationRepeatCount = -1;

You probably thought this would set the repeat count to infinity. However, the API states

The default value is 0, which specifies to repeat the animation indefinitely.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜