I have a UITableViewController that is embedded in a UINavigationController and I'm trying to implement Peek & Pop into the TableView. I have the "peek" part working perfectly, but when I try to "pop" into the next ViewController, the cell I was "peeking" and the next cell over are both shown. I am "popping" into a UICollectionView, and as I mentioned, the "peek" half shows the correct cell, but the "pop" does not. This issue only happens when I use [self.navigationController showViewController:viewControllerToCommit sender:nil];
or [self.navigationController pushViewController:viewControllerToCommit animated:YES];
to execute the "pop".
Here is the "Peek" showing the correct cell
And the "Pop" showing the wrong cell(s)
I tried to use [self presentViewController:viewControllerToCommit animated:YES completion:nil];
and the correct cell is shown, except this doesn't give me the navigational elements that I need, so I can't use it (unless there is a way to get all the navigational elements back).
My initial thought is that there is something wrong with how my app is figuring out the size of the CollectionViewCell. Here is the code that I'm using for that, though it appears that it works properly with everything other than 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);
}
To add to my confusion, the "pop" works perfectly when the first or last item in the TableView are "peeked". Any help with this would be greatly appreciated.
viewControllerToCommit
to aUINavigationController
and present thatnavigationController
to get all the navigational elements back – AaUINavigationController
and my data wasn't loaded into the new view' cell, and the only navigational elements that appeared was a BLANKUINavigationBar
and emptyUIToolBar
– Nubble