2011-03-10 2 views
0

내 앱에서 스플래시 화면에 애니메이션을 사용 중입니다. 지연이 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]; 
} 
+0

같은 tochesBegan 방법 stopAnimation 방법 당신은 어쨌든, 당신의 시작 루틴을 재고해야한다. 응용 프로그램은 사용자가 "멀티 스레드 느낌"을 경험할 수 있도록 가능한 빨리 시작해야합니다. 일부 개발자는 앱을 빨리 시작하는 데 많은 시간을 할애합니다. 사용자가 처음으로 애니메이션을 보는 경우 애니메이션이 좋을 수도 있습니다. 2 ~ 3 번의 시동 이후에는 이상하게 느껴질 수 있습니다. –

답변

1

문제 없어

호출이

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    YourAppDelegate *obj=(YourAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    [obj stopAnimation]; 
} 
+0

좋아요, 구현했지만 컨트롤이 touchBegan 함수에 적용되지 않습니다. 위의 코드를 appDelegate에 모두 씁니다. –

+0

수정 된 답변보기 참조 – Ishu

+0

하지만 문제는 컨트롤이 tochesBegan 함수에 적용되지 않는다는 것입니다. BTW 무엇이 1 행에 들어가는가. –

관련 문제