I have a view that looks like this.
Container View 3&4 are stacked together on the far right.
3rd container view is under the 4th container view.
I want the views to be stacked, however the 3rd container view gets pushed down to the bottom below the 4th container view.
Why is this and how can I prevent this from happening?
The issue was that despite removing the 3rd container view, my view was still not showing up.
I add to bring it to the front.
[self.view bringSubviewToFront: self.fourthContainerView];
Related
I have a view controller which contains a table view controller embedded in a container view:
What you see inside the view controller on the left is a container view that embeds the table view controller through a storyboard segue. And like you see in the image, there is also a constraint that specifies a top space between the container view and the above segmented control.
When I launch the application everything is normal and I can see a separation space between the segmented control and the table view cells. But as I scroll down, as you see in the blow picture the table view cells overlap with the segmented control:
By debugging the view hierarchy I found out that the problem is that the cells are displayed even if they are outside of the container view:
What you see in the above pictures are the table view cells and the container view. I've drawn two red lines, one starting from the container view top and one starting from the top of the first table view cell and like you see the table view cells go beyond the bounds of the container view, which means that they are visible even if they are outside of the table view area. Instead, the container view which embeds the table view is below the segmented control and the separation space imposed by the constraints is respected.
Can you try setup clipsToBounds? It can be help.
tableView.clipsToBounds = true
Must be something to do with how you've laid out your constraints. Hard to tell by the pictures.
I set a height constraint to the view that has the segmented control. And set the vertical spacing between that view and the container view to 0.
I uploaded a demo project here.
I have a table view controller with static cells. I’m running on iPhone X and when scrolling, the cells appear to be behind the navigation bar and unsafe area. What is preferred would be a solid orange color in the unsafe area instead of the image presented below. Is this possible? I can’t move to a table view inside of a view controller, which I would then constrain to the safe area, because my cells are static.
You need to use a Container View, so add a View Controller in your storyboard and put a Container View in it-by adding the container view it will automatically create a segue and a view controller delete both.
Now from your Container View create a segue to the Table View Controller and choose Embed.
Last step is to set the constraints for your Container View, the most important for your issue is the top one, set it 0 to the safe area.
My iOS app view has a cover Image at top (100% width, 30% height) and a Table for the rest of the screen. To acheive this kind of layout, I am using "Container Views" in my view. So I have Two Container Views:
1st Container is normal view controller with UIImage.
2nd Container is Table View Controller. This can have many entries.
When I run this and try to scroll, only the second container scrolls in place. 1st container remains at the top.
How can I make the full parent view to scroll instead of just second view.
(Are container views right bet for this kind of requirement and layout?)
you may create a new cell called "HeaderImageCell", and make the first cell to be "headerImageCell"
"Container Views" is not needed at this point.
I would like to move a textview inside a container view without deleting or re-creating them. How can I do it using my storyboard ? I just want to move highlighted Text View inside to Container View. Drag & Drop is not working, it is just changing the order of views.
Guidance needed. Thanks.
If container view is of container kind. Drag should work I believe. Just drag your textView over containerView and hold until your container get surrounded by blue line like in image then drop it there.
If you see here I am dragging and dropping Label 0 - 12 inside a collection view.
I'm trying to add my custom ContainerView to an usual ViewController using StoryBoard (iOS7).
I only have a TableView Controller on this view. If I move the ContainerView inside the TableView it is displayed (but moved with the table items), but if I place it directly on view it is not displayed any more! Any ideas?
There appears to be a bug in Xcode/iOS where if the container view is the first child of self.view in storyboard, it doesn't show. For example when I have:
my container doesn't show.
But if I move the label above the container view in the outline:
Then my container view and the label will show.
UPDATE: Upon further investigation it appears the container view does still show if it is the first child, just much lower than you would expect it to appear. Placing another element above the container view allows the container to appear in the position you would expect (the position shown in storyboard).