Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "Inferred" and "Freeform" in Xcode Storyboard?

I have a custom view which needs to be displayed on all the iPhone devices(4, 4S, 5, 5S, 6 and 6 Plus). When creating the custom view XIB, I have mentioned it as "Inferred" but it is not resizing for iPhone 6 and iPhone 6 Plus devices. I am not able to figure out the issue. I am confused on what would be actual differences between "Inferred" and "Freeform". Can someone please explain the differences?

like image 264
Pradeep Reddy Kypa Avatar asked Sep 28 '15 09:09

Pradeep Reddy Kypa


People also ask

What is storyboard interface in Xcode?

Storyboarding is a feature built into Xcode that allows both the various screens that comprise an iOS application and the navigation path through those screens to be visually assembled.

Is there any way to use storyboard and Swiftui in same iOS Xcode project?

Yes you can do that! Here are the steps you can take to do so: Go to your current Xcode project -> Storyboard, click on the + sign (right upper corner) and search for Hosting Controller (just like you would for a button or label). Drag Hosting Controller to your Storyboard.

How do I see Storyboard in Xcode?

To get this, open the storyboard, click the 'assistant' editor, click the 'assistant editor menu button' (immediately to the right of the > arrow at the top left of the assistant window) and select Preview.


2 Answers

Inferred resizes the scene according to its parent scene. For example if you have a scene that is the size of an iPad and then you add a new scene to your storyboard and create a segue to it, it will automatically resize to the same size as the iPad scene (where the segue originates from).

Freeform ignores the above rule and you're able to size it as you see fit, in the utility pane on the right.

Both of these however have nothing to do with how the view is displayed and sized on actual devices. For that you need to use auto layout and constraints. Or springs and struts. Some even do it in code if they need more flexibility.

like image 161
Robert J. Clegg Avatar answered Nov 09 '22 23:11

Robert J. Clegg


“Inferred” is the default setting for storyboards and it means the scene will show a navigation bar when it’s inside of a navigation controller, a tab bar when it’s inside of a tab bar controller, and so on. You could override these settings if you wanted to, but keep in mind they are here only to help you design your screens. The Simulated Metrics aren’t used during runtime, they’re just a visual design aid that shows what your screen will end up looking like.

"FreeForm" Usually you use the freeform property when you add the view controller as a child to another view controller programmatically and you really want to have that fixed size.If you push the view controller or you present it as modal view controller (and you use the modal presentation styles) then there is no need to use freeform.Also another use of the freeform property is to preview the actual size of your view controller when is presented as a modal view controller using existent presentation styles.

like image 43
Nirzar Gandhi Avatar answered Nov 10 '22 00:11

Nirzar Gandhi