2013-02-13 4 views
0

이상한 버그가 있습니다. 내 앱이로드되고 애니메이션을 수행하기 위해 버튼을 탭하면 애니메이션에 커밋하지 않지만 두 번째로 시도하면 완벽하게 작동합니다. Heres 내 코드 :애니메이션이 처음 실행되지 않습니다.

-(void)Revert 
{ 

    firstTable.hidden = FALSE; 
    self.navigationItem.leftBarButtonItem = NO; 
    [self returnanimation]; 
} 

-(void)returnanimation 
{ 
    CGRect labelframe = childnamelabel.frame; 
    labelframe.origin.x = 493.5; // new x coordinate 
    labelframe.origin.y = 359; // new y coordinate 
    CGRect textframe = passwordfield.frame; 
    textframe.origin.x = 454; // new x coordinate 
    textframe.origin.y = 388; // new y coordinate 
    CGRect submitframe = submit.frame; 
    submitframe.origin.x = 640; // new x coordinate 
    submitframe.origin.y = 387; // new y coordinate 

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration: 0.25]; 
    childnamelabel.frame = labelframe; 
    passwordfield.frame = textframe; 
    submit.frame = submitframe; 
    [UIView commitAnimations]; 
} 

-(void)animation 
{ 


    CGRect labelframe = childnamelabel.frame; 
    labelframe.origin.x = 335.5; // new x coordinate 
    labelframe.origin.y = 359; // new y coordinate 
    CGRect textframe = passwordfield.frame; 
    textframe.origin.x = 294; // new x coordinate 
    textframe.origin.y = 388; // new y coordinate 
    CGRect submitframe = submit.frame; 
    submitframe.origin.x = 480; // new x coordinate 
    submitframe.origin.y = 387; // new y coordinate 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration: 0.25]; 

    childnamelabel.frame = labelframe; 
    passwordfield.frame = textframe; 
    submit.frame = submitframe; 
    [UIView commitAnimations]; 
} 

-(IBAction)PressedTeacherButton: (UIBarButtonItem*) Teacherbutton 
{ 
    [self setNameLabel: @"Mrs Hayward" Child:[NSNumber numberWithInt:0]]; 
    firstTable.hidden = TRUE; 
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(Revert)]; 
    [self animation]; 

    //Pass on admins name and also bool whether they are a child. 
} 

시도했지만 해결책을 찾지 못해 아무것도 찾을 수 없습니다. 도움을 주셔서 감사합니다 : D

* UPDATE

는 애니메이션이 애니메이션 전이나 후에 라벨을 변경 좋아하지 않는 것 같습니다 [self setNameLabel: @"Mrs Hayward" Child:[NSNumber numberWithInt:0]];로 좁혀. 완료 기능을 시도한 후 애니메이션을 적용한 후 레이블을 변경 한 후 즉시 원래 위치로 다시 설정합니다. BOT BY

요청이 setnamelabel 방법을 올려 :.

- (void) setNameLabel:(NSString *)sender Child:(NSNumber *)Child 
{ 
    self.childnamelabel.text = sender; 
    IsAChild = Child; 
} 

아직 답이없는 :(를

코드가 잘 보이지만, 내가 잠시 다시 유사한 문제가 있었다
+0

이'sentNameLabel 게시 사용해보십시오.'메소드 코드를 – ColdLogic

+0

어떤 iOS 버전을 사용하고 있습니까? – Bot

+0

iOS 버전 6.1을 사용하고 있습니다. – user1816481

답변

0

나는 블록을 사용하여 전환과 . 아이 : 일

것은

-(void)animation 
{ 
    CGRect labelframe = childnamelabel.frame; 
    labelframe.origin.x = 335.5; // new x coordinate 
    labelframe.origin.y = 359; // new y coordinate 
    CGRect textframe = passwordfield.frame; 
    textframe.origin.x = 294; // new x coordinate 
    textframe.origin.y = 388; // new y coordinate 
    CGRect submitframe = submit.frame; 
    submitframe.origin.x = 480; // new x coordinate 
    submitframe.origin.y = 387; // new y coordinate 

    [UIView animateWithDuration:0.25 animations:^{ 
     childnamelabel.frame = labelframe; 
     passwordfield.frame = textframe; 
     submit.frame = submitframe; 
    }]; 
} 
+0

도움을 주셔서 감사합니다. 불행히도 그것은 전혀 다른 것을 만들지 않았고, 미리 시작하기 전에 애니메이션을 해보려고 시도했지만 여전히 아무것도하지 못했습니다! 괜찮아요 : ( – user1816481

+0

좋아요. 나는 [self setNameLabel : @ "Mrs Hayward"Child : [NSNumber numberWithInt : 0]]를 주석 처리하고 이번에는 작동하지만 이상한 오류는 있지만 해결하려고합니다.) – user1816481

+0

다른 시청자의 편의를 위해. 이전 주석에서 주석 처리 한 방법은 애니메이션으로 될 레이블을 변경하는 것이 었습니다. 애니메이션을 적용하기 직전에 값을 변경하는 것이 싫은 것처럼 보입니다. 이상한 오류 : P, 애니메이션 후 – user1816481

관련 문제