iOS different default margins - ios

I'm designing my views both with a storyboard, and in a few .xib files for views that I instantiate programmatically. I also have some UITableViews, added from the storyboard.
I'd like to have consistent margins across my views. For now I have 3 different values:
a value for my table views
a value for the views I designed in my storyboard
a value for the views I designed in a .xib file
Here is a screenshot showing the problem (left: .xib view, middle: table view, right: storyboard view):
In the GUI builder, I always check the "Constrain to margins" checkbox, so that the margins are different depending on the device (which is nice). Having a different value for the table views is no big deal, but having different values depending on the way I designed the view (.xib vs storyboard) is really annoying.
Is there any way to have the same value everywhere, or at least in .xib and storyboard views?

Related

How to give constraints to a tableview when tableview cell is on xib. And table view is on storyboard

I have a table view on storyboard i.e. FirstStory.Storyboard. And for this tableview I have created a table view cell on xib file where I give size to its width as per my current storyboard width. But when I launch my app it runs fine on the landscape position. But when I rotate it in the portrait mode. Width is unable to show the all item which I placed in tableviewcell.xib. How we mutually combine these two item in storyboard (table view on storyboard while cell on xib). Which follow a single constraints with above condition.
UITableViewCell's contentView property is always the size of the cell. So you have to setup the constraints of your UI components in the xib file with the Cell's contentView properly. The issue you are facing must be because you did not setup these constraints properly.
To see which views or constraints have been placed wrong, use the XCode's 'Debug View Hierarcy' feature.
Launch it from here
Run your app, navigate to your tableView, then press the above button to launch the view debugger. It provides very good insight into your constraints and where the issue may lie

How can I use a xib with auto layout in iCarousel?

I have an iCarousel set up to reuse a certain xib. This xib is using AutoLayout (as I am in the rest of my project). Apparently iCarousel does not use AutoLayout, and it does not work correctly with it. The view's constraints appear to be calculated for another frame, and then the view seems to resize...
I have an example project showing my setup here
Here are some images of my troubles:
The first view is correct:
The second and all the others screw up in another way:

Handling multiple Xib or fixing collapse and expand button on multiple Xib file

Now the situation is illustrated in this image:
I have an app having multiple Xib files calling in one main Xib and its class. I have added expand and collapse view which works on particular xib expand and collapse subviews as required and reduces/Expands Height too.
This works well for one xib section when all tabs of xib files are collapsed and the second xib won't change its y-coordinates, but I'm having a white space between. I want to fix it.
Note: Every xib contains a class referring to it. The whole app won't use auto-resize.
How can I solve this?

UICollectionView does resizing when embedded in a container view

I have a view with two container views with different background colours. I am using auto layout. Both container views size themselves correctly (going by the colours). The first view just has a button in it and the child view sizes itself correctly and aligns the button as expected.
The second view has a UICollectionView as the top level view does not size itself. The collection view (with a different background colour) seems to flow off the side of the whole screen. It is definitely way bigger that the container view that it is embedded in.
The Container view has "Autoresize children" set (tried it both ways). I've tried different modes for the container: top, scale, aspect fit.
The Collection view has "Autoresize subviews" set (tried it both ways). I've tried various different modes: Scale, top, aspect fit. The collection view has a custom layout but the problem happens whether it is specified or not.
Does anyone have any ideas on how I can get my UICollectionView to resize itself to match it's parent? I am using Swift it it makes a difference.
I am running XCode 6.4.

Resizing UITableView with a table header in UIScrollView using auto layout

I have one simple UIView and three tables nested in the UIScrollView. The first two tables have table headers included. The third (orange) table has no header view and it is resized correctly according the data it uses. The picture displays the closed state of the scroll view. UITableView_A and UITableView_B are closed, UITableView_C opened. The data are ready for use in all tables, and also the cells are being created.
Also in xib I have connected the layout constraints to the properties from the subclass of UIScrollView. The constants are specific sizes as UIScrollView demands it for its nested views.
The issue:
The views are being resized correctly but when I update the constants for heights of the tables without the header views (the first two tables, green and pink) I manipulate only with the header views. Which is odd. The auto layout constraints for the green and the pink table are setup correctly in the xib file. I was checking the resized tables in the simulator using introspection tool and I realized the first two resized tables are not tables BUT only the header views.
The height of cells is 44 and headers also 44. The tables are not scrollable.
Closed state:
Opened state
When I update the auto layout constants related to any table I call this line afterward
[self layoutIfNeeded]; //(scroll view)
UPDATE 1:
When I remove the header views from the tables, then the resizing works perfectly for the tables. I am really curious why I manipulate just with the header views instead of the whole table when the constraints is defined on the table view NOT on the table header view.
I replaced the table header views with the section header views and the resizing works smoothly. I'd be glad to know the explanation for the previous problem.

Resources