이상한 버그가 있습니다. 내 앱이로드되고 애니메이션을 수행하기 위해 버튼을 탭하면 애니메이션에 커밋하지 않지만 두 번째로 시도하면 완벽하게 작동합니다. 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;
}
아직 답이없는 :(를
코드가 잘 보이지만, 내가 잠시 다시 유사한 문제가 있었다
이'sentNameLabel 게시 사용해보십시오.'메소드 코드를 – ColdLogic
어떤 iOS 버전을 사용하고 있습니까? – Bot
iOS 버전 6.1을 사용하고 있습니다. – user1816481