UICollectionView embedded in UICollectionViewCell acting weird with UINavigationController - ios

I have a UINavigationController that has a UIViewController at its root. I have a UICollectionView that fills the UIViewController. My look that I'm trying to go for is a navigation bar that hovers over this collection view. For this I have pinned the UICollectionView to the top of the superview instead of to the top of the Safe Area. I've also turned off adjust scroll view insets.
Inside my collection view I have a cell that has a UICollectionView embedded in it. When I start scrolling, the embedded UICollectionView seems to decrease in size slightly as it goes past the UINavigationBar. I should note that if I instead pin my outer UICollectionView to the Safe Area, this problem doesn't occur!
How can I solve this? Is there a better way to make the UICollectionView ignore the nav bar instead of pinning it to the top of the superview?

Related

How to put a UIView in a UITableView and It will be pinned on the bottom

I am trying to build a UITableView Controller, which will be my app's ABOUT information session.
At the bottom of the view, it will be reserved as circle menu. So I need a UIView with height of 200 there, when I drag a UIView to the controller, it always sit as a table cell.
As you can see, the red area always sit under the last table cell group, how to pin it on the bottom of the View Controller.
Thanks in advance.
You can't add a UIView at the bottom of the UITableViewController. If that is a hard requirement you have to switch to UIViewController. And then you can use UITableView and other UIView's as well.
If you are using a navigation controller with UITableViewController then you can use UIToolBar which sticks at the bottom of view controller but have some limitations too. See this
Get UIView controller and put tableview instead of UITableViewController. From side inspector drop UIView out of tqbleview. And in inspector menu for UIView set auto resizing mask for UIView according.

Putting a UIScrollView inside a UIPageView, scrolling doesn't work

I'm making a pageview that has a bunch of scrollable pages inside it. I have the pageview working, and the viewcontrollers that it rotates each have a scroll view inside them. The problem is, I think, that the scrolling doesn't happen because the touches don't get through to the pageview. The scroll view should only scroll vertically, while the pageview works with the horizontal scrolling. Is it possible to send through only the vertical touches, or is there another way?
Thanks
If you're using a storyboard, open the Attributes inspector of the embedded UIScrollView and deselect the "Shows Horizontal Indicator" option. Do the same on the UIPageViewController, but for the "Shows Vertical Indicator". However, you also have to ensure that the scroll view's contents aren't wider than the scroll view itself; to do this, just constrain the contents' width to be equal to the scroll view's parent.

UITableViewController within UIContainerView

I have a static UITableViewController embedded within a UIContainerView. All created using Storyboards.
I'm setting the positioning of the container view using autolayout, whereby it is always touching the top, left and right of the uiviewcontroller it is within and always 50px from the bottom due to a UIButton being there.
The UITableViewController has a larger content size than the height of the container view, so one would expect you to be able to scroll the tableview from the container view.
But for some reason I cannot get it to work, when you initially load the UIViewController the scroll indicator appears and then hides and it won't let you scroll the tableview. How would I solve this?
(It has previously worked for me, I just can't remember what I did.)

Adding a fixed-position view on top of a view

I have a UITableViewController inside a UINavigationController. I'm adding a "modal" subview to the tableView, which is a custom UIView when one of the rows is selected.
(It’s modal in spirit, not in the UIKit sense, since Apple doesn’t support modal views on iPhone, I’m adding it with a [self.view addSubview:customView] in my table view’s controller.)
I would like it to appear at the bottom of the screen and stay put there. I can get it to draw at the bottom, but once I scroll the table view, the view moves with it. Here are some illustrations:
Initial position (good):
Position after scrolling (bad):
I'm getting the bottom position by subtracting the height of all the chrome (navigation bar and status bar) as well as the height of the custom view from [UIScreen mainScreen].bounds.
How can I get the custom view to stay put? Should I constantly be adjusting its frame when the table view is being scrolled?
Your best and most flexible option is to switch to using a view controller with the table view as a subview so that you can change its frame and add sibling views. Then, when you want to add a modal you can run an animation to move the table view out of the way and slide the modal view in.
UITableViewController.view is an instance of UITableView. Means you added your custom view into a scroll view and that is why it scrolls. You can try to put your custom view into the tableFooterView property of the UITableView, which is the old school solution.
Personally I would create a container UIViewController and have UITableViewController be a sub viewController of it. Another sub viewController UIViewController or just a simple UIView could represent the footer.

UITableView with a UIView underneath the Cells

I have a UITableView and below the custom cell (in IB) I have inserted a UIView. The UIView gets set to hidden when viewDidLoad() gets called and is only displayed when there is no data in the UITableView. This works great and servers my purpose.
The problem is that even when the UIView is hidden, the scrolling on the UITableView considers the view to be present. i.e. The vertical scroll with scroll well below the last cell, covering the area where the UIView exists - even though its blank and nothing is displayed.
I have tried to hide the UIView but this doesn't help either. How do I get the scroll to not extend to the area covered by the UIView?
Edit:
The image on the left is how IB looks. I have added a UIView as a subview of the TableView. The image on the right is the large scroll space below the last cell.
Expected behavior: When the view is hidden, the scroll view only scrolls until the last cell.
If your view is displayed only when there is no cells, you could just add it over your UITableView (or behind it if your UITableView's background is clear) and hide it when you have cells to display. Just be sure to add your view as a sibling of your UITableView and not as a child view of your UITableView.

Resources