1
我有以下幾點看法層次iPhone:動畫視圖另一個視圖時出現/消失
的UITabBarController - UINavigationController的 - 的UITableViewController
當表視圖顯示(動畫)我創建了一個工具欄,並將其添加作爲頁面底部的TabBar的子視圖 ,並讓它與表視圖一起動畫。當表格視圖消失時,在其他方向執行相同的過程。
它沒有按預期工作。
- 動畫持續時間是確定的,但是當它變得可見
- 當我顯示第二次表視圖,工具欄不會消失都以某種方式不準確一樣的表視圖的動畫並保留在父視圖的底部 父視圖。
它有什麼問題?
- (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];
}
你的意思是導航控制器的工具欄,對吧?我需要在表格底部的另一個工具欄,但在上下滾動時不應隨表格內容一起移動。 在上面的代碼中,我試驗了一點動畫,但工具欄只有在表格變爲編輯模式時纔會顯示。 嗯......再次將UIViewController作爲UITableViewController的「容器」可能是一個解決方案。 – MacTouch 2010-03-16 16:50:59
好的,使用一個簡單的UIViewController而不是UITableViewController來解決它。它的作用類似於以下示例:http://iphonedevelopment.blogspot.com/2008/10/table-view-multi-row-edit-mode.html – MacTouch 2010-03-17 10:55:10