내 앱에서 스플래시 화면에 애니메이션을 사용 중입니다. 지연이 5 초 후에이 애니메이션이 멈 춥니 다. 하지만 사용자가 중단 (터치) 애니메이션을 중지해야하는 경우 5 초 전에이를 원합니다.터치 이벤트를 통해 스플래시 애니메이션 중지
애니메이션을 위해 나는 쓰고 :
- (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];
// 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 makeKeyAndVisible];
// Start it up
//animatedImages.startAnimating;
[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];
}
같은
tochesBegan
방법stopAnimation
방법 당신은 어쨌든, 당신의 시작 루틴을 재고해야한다. 응용 프로그램은 사용자가 "멀티 스레드 느낌"을 경험할 수 있도록 가능한 빨리 시작해야합니다. 일부 개발자는 앱을 빨리 시작하는 데 많은 시간을 할애합니다. 사용자가 처음으로 애니메이션을 보는 경우 애니메이션이 좋을 수도 있습니다. 2 ~ 3 번의 시동 이후에는 이상하게 느껴질 수 있습니다. –