i have a problem. I had a storyboard in Xcode 6 with the inferred size of the view controller and the "Use Auto layout" option checked. Today i wanted to use the new " Use Size Classes" option. I checked the option and then in the simulator the screen was all black!
EDIT
now that i resolved this issue i have another thing here ! I use "Add missing costraints" option to have a resize for all Apple Device, the Tab bar and navigation bar are good, but then all the buttons ( they have an image ) are in different position !
How i can resolve that ? Thanks in advance.
A black view.. if not always, is a good indicative that the view is not loaded. Size Classes introduces a new concept ...You can have several views that will be installed or not into your view depending of your view configuration. More details on images below:
This is what you will be looking for:
This is what I call view rendering configuration (sure Apple has another name for it). It is located at center bottom of your storyboard view.
This is always located at the end of Attributes Inspector tab:
Make sure it is enabled for the view that suits your testing device.
I found out that the ViewController wasn't set as Initial Controller.
You should avoid as possible the use of "add missing constrains". Is an automatic tool that almost always ends up adding unnecessary constrains or breaking others.
If you want something to look really good an stable, sadly there are no shortcuts... you will eventually end having to do it all by yourself.
Related
I want to layout my labels like this using auto layout. It works fine in iPad 10.5. But when I move to any other versions of iPad with a larger screen, this design brokes. Anyone, please help me to solve this problem.
Swift 4
Use stack view
Step 1. insert labels inside of stack view
like that
Step 2. add constraints on stack view
from top, bottom, left and right alignment according to your requirement
like that ->
Step 3.
Use Stackview properties
a.) set axis of Stack view Horizontally as well as vertically.
b.) set alignment according to requirements.
c.) set Distribution according to requirements (here i used fill equally).
b.) set Spacing between labels .
See here ->
Now run. it will work, it will show same in all Device like iPhone and iPad and also (horizontal and vertical).
it will show like this(iPhone6splus)
Thank you
It seems like you create/checked constrations only for iPad or iPhone. Change a type of device scoping on Storyboard editor and you can find errors. Take care about UI for all of device types.
You can add constraints by "Add missing Constraints".
1.select your labels
2.And click the "Add missing Constraints"
I currently updated to Xcode 8 GM.
When I try to see my storyboard, above window pops up and there's no way to avoid this settings.
I chose 6s screen and all my view controllers changed to 6s size.
It will be much harder to adjust layout constraints on that small screens.
I believe it's possible to change the size to iPad but I want to know what this is first.
No way to comeback to ambiguous sized view controllers?
What is this settings for?
A way "come back to ambiguous sized" can be:
Select all the Scenes(View Controllers) in the Storyboard, show the Size inspector, change the Simulated Size to Freeform, then set Width Height = 600.
Then, those tons of warnings disappear.
In Xcode 8.1 updated version, there is a shortcut button for this.
For cases, when only updating of the Xcode fired these warnings, just select the problematic view's superview (containing mentioned constraints), and click this update frames button:
Select warning in the Scenes (View Controllers)
Select 'Update Frames'
Check 'apply to all views in the container'
Select 'Fix Misplacement'
Or
Select View in the Scenes (View Controllers) in the Storyboard
Select 'Resolve Auto Layout Issues'
Select 'All Views -> Update Frames'
Then, those warnings disappear.
Its easy to do in XCode 8.1
pedrouan answer is perfect. I am just adding the same answer in pictorial representation.
I just opened up my xib file of complex cell and its a lot of warnings; You can see in following picture:
You just need to select top level view/cell in xib hierarchy and click 'Update Frames' button; Everything will become perfect.
All warnings will gone like following screenshot:
Does anyone know why I get the following message:
"The selected views have no constraints. At build time explicit left, top, width, and height constraints will be generated for the view."
I'm using XCode 5 - Storyboard with AutoLayout turned on
Found the solution!
Select the ViewController then from the XCode menu:
Editor --> Resolve Auto Layout issues --> Add missing constraints in View Controller
It appears that in Xcode 5.1 when using AutoLayout, when you create a new scene it will start without any editable constraints. They are generated at runtime to reflect the scene's intended layout.
So adding constraints in interface builder is not needed only if you wish to modify the defaults. When you do that you need to familiarize yourself with the provided tools (as seen in the "Resolve auto layout Issues" menu)
In a ideal wold layout just works without thinking to constraints, even if they work behind the scenes. It seems to me a step towards that goal. This is not to start a debate if the goal can be reached, only to say that we can expect more similar interface builder / xcode changes to follow.
You have selected auto layout on your viewcontroller , so you can't set the contraints manually , uncheck the layout , it will show the constraints automatically .
I'm trying to layout a very simple view. I've placed 4 custom buttons in the view in a grid like spacing. But when I run the app I get two of the buttons with different sizes. I've included the storyboard and simulator images here.
I would LOVE to disable constraints but cant find where to do it! I really don't want them. This is just for a simple prototype app and in the end I won't even have these buttons, I'll lay everything out in code.
I've tried dragging in 4 individual buttons AND tried just dragging in one and duplicating it to where I want. I just want them to stay where I put them! Any help would be appreciated.
-Mark
You turn it off in the File Inspector (first tab on left) -- there's a checkbox called "Use Autolayout" (it's checked by default).
I have a UITabBarController as my rootController with 8 UITabBarItems. and I want to show just 4 UITabBarItems in my screen. By default all my other tab bar items appear in a small tabBarItem called "More" and you can select the other 4. But I have seen some apps that implement a sliding UITabBarItems with a slide icon instead of a "More" icon.
How can I show just 4 at a moment, and I slide the TabBarItems, and so that I can select the other tab bar items ?
~ Something like this ~
And then I can slide to the next 4 sets by dragging
It would be helpful if someone could point me in the right direction.
There is a nifty little github project that could help you... check it out: https://github.com/iosdeveloper/InfiniTabBar
This is not currently a built-in option for UITabBarContoller.
One way to approach the problem is to add a UIGestureRecognizer to the tabBar.view, and programmatically adjust which 4 options are available on the screen. You can add an animation to make it smooth or have a little bounce as it slides.
iPhone users are usually very picky and attached to Apple's UI Guidelines. Although you can pass the Apple verification, you probably wont be able to pass users' (meaning bad reviews and ratings). So I recommend you to re-consider your tabbar structure and use "..." More instead of sliding it... You can always override stuff in code, but then they wont work smooth with InterfaceBuilder and in the end you will have more trouble than you'd expect.
If you have similar tab items merge them and use maybe a segmented control or something to visually distinguish them. Or use a central navigation screen in which you can put 9 maybe more icons in a grid...
The first solution to your problem may not always be the best way. Well, it is very rare actually...
You have to write a custom control for this.
I wrote one for showing a horizontal menu. You can probably modify that to fit your needs.
http://blog.mugunthkumar.com/coding/ios-control-mkhorizmenu/