2012-09-20 3 views
1

이제 iPhone 응용 프로그램에서 UIImageView를 사용하여 애니메이션을 만들고 잘 작동합니다. 그런 다음 애니메이션이 끝난 후 애니메이션을 한 번 호출하면 화면에 표시되는 버튼이 표시되지만 처음에는 해당 버튼이 표시됩니다. 애니메이션이 시작되면, 애니메이션이 완성되면 화면에 단추가 나타납니다.이 문제를 해결하는 방법은 무엇입니까?iPhone에서 UIImageView 애니메이션을 설정하는 방법은 무엇입니까?

- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 


     NSArray * imageArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"cardopen.png"], 
             [UIImage imageNamed:@"middlecard.png"], 
             [UIImage imageNamed:@"thirdcard.png"], 
             [UIImage imageNamed:@"a.png"], 

             [UIImage imageNamed:@"cardopen1.png"], 
             [UIImage imageNamed:@"middlecard2.png"], 
             [UIImage imageNamed:@"thirdcard1.png"], 
             [UIImage imageNamed:@"2.png"], 

             nil]; 

     UIImageView * cardsImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 400, 300)]; 
      cardsImage.animationImages = imageArray; 
      cardsImage.animationDuration = 8.0; 
      cardsImage.animationRepeatCount=1; // one time looping only 
      [self.view addSubview:cardsImage]; 
      [cardsImage startAnimating]; 

      [self method1]; // To Call a method1 to show UIButton (Once the animation is completed, then to call a method1) 

    } 

    -(void)method1 
    { 
     UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
     btn.frame=CGRectMake(10, 40, 50, 50); 
     [self.view addSubview:btn]; 
    } 
+0

입니다. –

+0

럼 귀하의 method1 8 초 지연 후 – Rajneesh071

답변

2

가 (왜 아무도 비동기 방식의 개념을 이해하지 못하는이 그 하드인가?)

을 :

내가 참조를 위해이 시도가 사전에 나에게

감사를 도와주세요

[cardsImage startAnimating]; 

은 애니메이션이 끝난 후가 아니라 즉시 반환됩니다.

NSTimer *tm = [NSTimer scheduledTimerWithTimeInteral:imageView.animationDuration * imageView.animationCount // assuming animationCount is not 0 
    target:self 
    selector:@selector(method1) 
    repeats:NO 
    userInfo:nil]; 
+0

답장을 보내 주셔서 감사합니다 – SampathKumar

+0

고마워요 – SampathKumar

0

당신이 ViewDidLoad에 모든 코드를 가하고 있습니다 때문입니다 : 당신은 명시 적 제한 시간을 설정해야합니다. 전체 방법이 처리됩니다. 또한 애니메이션 기간이으로 0.8으로 설정되어 있습니다. 느린 애니메이션입니다. 버튼이 정상적으로 나타나고 애니메이션이 계속 그 다음에 계속됩니다. 그래서 당신이 실제로해야 할 일은 시작에 애니메이션을 nstimer를 사용 NSTimer를 사용하거나 여기에 제공되는 답변을 사용 :

1

사용
[self performSelector:@selector(method1) withObject:nil afterDelay:8.0];

대신 [self method1];

+0

답장을 보내 주셔서 감사합니다 – SampathKumar

+0

내 개념은 H2CO3와 같습니다 ... H2CO3의 답변에 따르면 당신은 .h 파일에서 이미지보기를 선언해야하고 내 코드가 필요 없어 .... – Rajneesh071