2
현재 애니메이션과 관련하여 iOS 개발에 문제가 있습니다. 현재 제스처 인식기가 실행 된 후 탭 표시 줄 항목을 전환하기위한 "슬라이드 애니메이션"을 만들기 위해 다음 코드를 사용하고 있습니다.UITabBarController 탐색 애니메이션
-(void)slideToTab:(int)controllerIndex
{
if(controllerIndex >= 0 && controllerIndex < [self.tabBarController.viewControllers count])
{
// Get the views.
UIView * fromView = self.tabBarController.selectedViewController.view;
UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:controllerIndex] view];
// Get the size of the view area.
CGRect viewSize = fromView.frame;
BOOL scrollRight = controllerIndex > self.tabBarController.selectedIndex;
// Add the to view to the tab bar view.
[fromView.superview addSubview:toView];
// Position it off screen.
toView.frame = CGRectMake((scrollRight ? 320 : -320), viewSize.origin.y, 320, viewSize.size.height);
[UIView animateWithDuration:0.3
animations: ^{
// Animate the views on and off the screen. This will appear to slide.
fromView.frame =CGRectMake((scrollRight ? -320 : 320), viewSize.origin.y, 320, viewSize.size.height);
toView.frame =CGRectMake(0, viewSize.origin.y, 320, viewSize.size.height);
}
completion:^(BOOL finished) {
if(finished)
{
// Remove the old view from the tabbar view.
[fromView removeFromSuperview];
self.tabBarController.selectedIndex = controllerIndex;
}
}];
}
}
이 코드는 잘 작동 탭 표시 줄에 탭 표시 줄 항목의
,하지만 난 탭 표시 줄의 "추가"섹션에 위치하고 첫 번째 탭을 칠 때마다, 애니메이션 작업과 완성 된 부울에서 정지 완료 블록은 false를 리턴합니다. 탭 표시 줄의 "추가"섹션에서 이것이 발생할 수있는 이유는 무엇입니까?이 문제를 해결할 수있는 방법은 무엇입니까? 사용자 정의 탭 표시 줄의 전환을 구현