我有一個導航控制器,開始在一個表視圖。每行推入一個詳細的UIView。我想在Detail UIView上有一個「next」按鈕,它會彈出當前視圖,並使用相同的視圖控制器打開與父UITableView上的下一行相對應的視圖,而不返回到TableView。理想情況下,它會使用一些幻燈片或滑動動畫。推下一個細節UIView不會回到父母UITableView
想法?
我有一個導航控制器,開始在一個表視圖。每行推入一個詳細的UIView。我想在Detail UIView上有一個「next」按鈕,它會彈出當前視圖,並使用相同的視圖控制器打開與父UITableView上的下一行相對應的視圖,而不返回到TableView。理想情況下,它會使用一些幻燈片或滑動動畫。推下一個細節UIView不會回到父母UITableView
想法?
我想出了這一個。基本上,我加載下一個視圖並將其推到導航堆棧上,然後從堆棧中刪除當前視圖。對對象引用進行編碼很困難,但它起作用,動畫看起來不錯。
這裏是關鍵代碼片段:
我想通了這一個了。基本上,我加載下一個視圖並將其推到導航堆棧上,然後從堆棧中刪除當前視圖。對對象引用進行編碼很困難,但它起作用,動畫看起來不錯。
這裏是關鍵代碼片段:
NSMutableArray *allControllers = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
NSLog(@"Controller Count:%d", [allControllers count]);
NSInteger backCount = 2;
[allControllers removeObjectAtIndex:[allControllers count] - backCount];
[self.navigationController setViewControllers:allControllers animated:NO];
[allControllers release];
[self.navigationController popViewControllerAnimated:YES];
我做的方式:
// Push the blog view, but don't add to the stack by popping first.
[self.navigationController popViewControllerAnimated: NO];
[listViewController.navigationController pushViewController: detailViewController animated:YES];
的listViewController代碼與表視圖的父視圖。 detailViewController是您需要首先創建的一個,其中包含列表中下一個元素的詳細信息。
如果你想回去,那就是在在工作臺上,你需要略有不同的代碼:
// Fake a pop animation by pushing the controller, then pushing a dummy and popping back.
DummyController* dummy = [DummyController alloc];
[self.navigationController popViewControllerAnimated: NO];
[lListViewController.navigationController pushViewController: detailViewController animated:NO];
[detailViewController.navigationController pushViewController:dummy animated:NO];
[dummy.navigationController popViewControllerAnimated:YES];
這很好地動畫頁面過渡。