0
그래서 블록으로 전환 애니메이션을 배우고 싶었습니다. 그래서 저는 Apple의 문서에 가서 old method (without blocks)을 사용한 애니메이션의 예를 들었습니다. 코드 스 니펫 (약간의 수정)을 가져 와서 테스트했습니다. 그것은 UIView transistionWithAnimation이 작동하지 않습니다.
[UIView setAnimationDelegate:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kTransitionDuration];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.view
cache:YES];
if ([self.instructionsView superview]) {
[self.instructionsView removeFromSuperview];
[self.view addSubview:contentView];
} else {
[self.contentView removeFromSuperview];
[self.view addSubview:instructionsView];
}
[UIView commitAnimations];
// adjust our done/info buttons accordingly
if ([instructionsView superview]) {
self.navigationItem.rightBarButtonItem = doneButton;
} else {
self.navigationItem.rightBarButtonItem = flipButton;
}
지금 아래의 코드 블록 아래의 코드가 작동해야한다는 것입니다 내가 이해할 수에서
[UIView transitionWithView:self.view duration:kTransitionDuration options:UIViewAnimationTransitionFlipFromRight animations:^{
if ([self.instructionsView superview]) {
[self.instructionsView removeFromSuperview];
[self.view addSubview:contentView];
} else {
[self.contentView removeFromSuperview];
[self.view addSubview:instructionsView];
}
} completion:^(BOOL finished){
if ([instructionsView superview]) {
self.navigationItem.rightBarButtonItem = doneButton;
} else {
self.navigationItem.rightBarButtonItem = flipButton;
}
}];
와 코드 상단에있는 코드를 변환하는 나의 시도 완벽하게 작동합니다. 블록을 지원하는 iOS 4.2에서 테스트하고 있습니다. 그러나 그것은 움직이는 것처럼 보이지 않으며 나는 그것이 왜인지 이해하지 못합니다. 보기를 변경하고 애니메이션을 적용하지 않습니다. 도와주세요.