2010-03-16 5 views
1

I 다음 뷰 계층에게아이폰 : 다른보기가 나타날 때 뷰를 애니메이션/사라

UITabBarController가 이 - UINavigationController가 -있는 UITableViewController

테이블 뷰 (애니메이션)가 나타납니다

내가 만든 도구 모음 및 추가 페이지 하단의 TabBar 하위 뷰로 을 선택하고 테이블보기로 애니메이션을 적용합니다. 테이블 뷰가 사라질 때 다른 방향으로 같은 절차.

예상대로 작동하지 않습니다.

  • 애니메이션 기간 OK이지만 I는 두 번째 시간에 대한 테이블 뷰를 표시 할 경우, 툴바가 모두 사라지지
  • 표시되었을 때에 든 테이블 뷰의 애니메이션과 동일하게 정확하지는 상위보기 하단에 남아 있습니다.

무엇이 문제입니까?

- (void)animationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    UIView *toolBar = [[[self tabBarController] view] viewWithTag:1000]; 
    [toolBar removeFromSuperview]; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 44, 0); 
    [[self tableView] setContentInset:insets]; 
    [[self tableView] setScrollIndicatorInsets:insets]; 
    // Toolbar initially placed outside of the visible frame (x=320) 
    UIView *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(320, 480-44, 320, 44)]; 
    [toolBar setTag:1000]; 
    [[[self tabBarController] view] addSubview:toolBar]; 

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.35]; 
    [toolBar setFrame:CGRectMake(0, 480-44, 320, 44)]; 
    [UIView commitAnimations]; 
    [toolBar release]; 

    [super viewWillAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    UIView *toolBar = [[[self tabBarController] view] viewWithTag:1000]; 

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.35]; 
    [UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)]; 
    [toolBar setFrame:CGRectMake(320, 480-44, 320, 44)]; 
    [UIView commitAnimations]; 

    [super viewWillDisappear:animated]; 
} 

답변

0

테이블보기 컨트롤러의 toolbarItems 속성을 사용해 보셨습니까? UINavigationController은 현재 최상위 뷰 컨트롤러의 툴바 항목으로 툴바를 업데이트하여 툴바를 관리합니다. -viewWillAppear:-viewWillDisappear:에서 -setToolbarHidden:animated: 방법을 사용하여 해당 도구 모음의 표시 여부를 제어하십시오.

+0

내비게이션 컨트롤러의 툴바를 말하는 것입니까? 테이블 하단에 다른 툴바가 필요하지만 위아래로 스크롤 할 때 테이블 내용과 함께 이동해서는 안됩니다. 위의 코드에서 애니메이션을 약간 실험했지만 테이블이 편집 모드로 전환 될 때만 툴바가 표시됩니다. Hmmm ... UITableViewController의 "컨테이너"로 다시 한 번 UIViewController가 해결책이 될 수 있습니다. – MacTouch

+1

OK, UITableViewController 대신 간단한 UIViewController를 사용하여 해결했습니다. 다음 예제와 유사하게 작동합니다. http://iphonedevelopment.blogspot.com/2008/10/table-view-multi-row-edit-mode.html – MacTouch

관련 문제