【发布时间】:2016-06-02 07:41:57
【问题描述】:
我有一个嵌入在 UINavigationController 中的 UITableViewController,我正在尝试在 TableView 中实现 Peek & Pop。我的“窥视”部分工作得很好,但是当我尝试“弹出”到下一个 ViewController 时,我正在“窥视”的单元格和下一个单元格都显示出来。我正在“弹出”到 UICollectionView,正如我所提到的,“peek”一半显示了正确的单元格,但“pop”没有。仅当我使用[self.navigationController showViewController:viewControllerToCommit sender:nil]; 或[self.navigationController pushViewController:viewControllerToCommit animated:YES]; 执行“pop”时才会出现此问题。
我尝试使用[self presentViewController:viewControllerToCommit animated:YES completion:nil]; 并显示了正确的单元格,但它没有提供我需要的导航元素,所以我不能使用它(除非有办法获取所有导航元素返回)。
我最初的想法是我的应用程序计算 CollectionViewCell 大小的方式有问题。这是我正在使用的代码,尽管它似乎可以与 Peek & Pop 以外的所有内容一起正常工作。
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize collectionViewBounds = collectionView.bounds.size;
int navigationHeight = self.navigationController.navigationBar.bounds.size.height;
int toolbarHeight = self.navigationController.toolbar.bounds.size.height;
int statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
int cellHeight = collectionViewBounds.height - (navigationHeight + statusBarHeight + toolbarHeight);
int cellWidth = collectionViewBounds.width;
return CGSizeMake(cellWidth, cellHeight);
}
让我更加困惑的是,当 TableView 中的第一个或最后一个项目被“偷看”时,“pop”可以完美地工作。对此的任何帮助将不胜感激。
【问题讨论】:
-
您可以将
viewControllerToCommit添加到UINavigationController并呈现navigationController以取回所有导航元素 -
我尝试创建一个新的
UINavigationController,但我的数据没有加载到新视图的单元格中,唯一出现的导航元素是空白UINavigationBar和空UIToolBar跨度>
标签: objective-c iphone uinavigationcontroller uicollectionview 3dtouch