Main.storyboard changing views every time I restart my computer - xcode

I'm actually getting a problem with my main.storyboard. Every time I restart my computer the main.storyboard is changing two UIViewController whose are embed with a segue to an UITableViewController. This happen since I update Xcode and swift to the lastest versions (Xcode8 and Swift3).
It's look like the constrain are changing the width and height of three elements inside the view (UIView, UIButton and MKMapView). I don't know why but the height and width of those elements change to 1000. Here a picture of my storyboard:
I would like to know if somebody is getting the same problem and how could I solve it or if I'm doing something wrong with the xcode configuration.
Thank you in advance,

I fix this error by updating xcode8 to xcode 8.1, it seems it was a problem with the software.
Just have to readapt my elements to the respective constraints and all clear.

Related

Xcode Interface Builder 9.1 Collection View Cells have too small "expected height"

Recently, I encountered a problem with the Interface Builder which I failed to solve. I'm using a UICollectionViewController and whenever I add a Cell it immediately shows a orange rectangle (indicating a auto-layout update). Updating the frame/cell doesn't change anything. The warning associated with the orange marking reads "Expected: height=Y, Actual: height=X" where Y is always exactly X-100. That is: When I set a custom cell height of 193, it says "Expected: height=93". This happens no matter which size I enter.
The problem with this is that I have many difficulties with the subviews and their constraints. For instance, if I add a subview with the constraint to keep the same height as the cell, it will be shown as 93 (the expected height), even though my cell should be 193. Layouting becomes impossible.
I tried adding a new cell, same issue. I tried removing every subview and re-adding them, nothing.
Any ideas are highly welcome.
Thank you very much!
Solution found ! (Xcode 9.2)
The bug seems to only happen when you try to embed the UICollectionViewController in a Container View in the storyboard. The workaround is to remove the segue while you set your constraints, and re-add the segue once your constraints are well set.
I also think that setting UICollectionViewController size as Freeform could be responsible of the bug. If so, try to set constraints before changing the size.
Hope this helps !
I'm not sure if this solved it, but the warning and issue disappeared once I did the following:
Select the CollectionViewController in Interface Builder and set the size to freeform and make the height larger, large enough to show all your template cells. (Plus: maybe refresh the views). That solved the issue for me.
In my case, I have added two collection view cell, withing collection view Controller.Only setting the view controller to free form wont help us. Need to update the size, to get rid of the warning.
updating collection view cell frames, wont help us. Warning will be continuously changing its length.
I tried to work without considering the warning, as I have set my collection view cell size programmatically and it does working as expected.
I think it's just a strange bug
I delete the collectionViewController in SB, then create a new one, the problem disappear
This is a common bug with Interface Builder. I don't know the exact cause, but I believe it's something to do with placing collection views inside arrangement views that do not have an exact size. I've seen it when putting them in scroll views, stack views and container views.
There is a simple fix, although I believe this to be a bug in IB that ought to be corrected by Apple rather than hacking around it. The solution (for me at least - your mileage may vary!) is to place the collection view inside an ordinary UIView and pin its edges to it, then place that parent view in the position that you wanted your collection view with all the constraints it required.
I usually found that there were actually no auto layout issues at run-time, which is why I believe this to be purely an Interface Builder bug.

UITableviewcell width not filling the screen

I don't know if this is a bug with AutoLayout or Xcode but I've realised that if I run my application on a device which isn't the same size as the device in my storyboard, the elements are adopting the incorrect size.
I.e. Selecting View as iPhone SE and running the application on an iPhone 7+ The size of my tableview is the width of an iPhone SE screen, this fixes itself when I reload the view and then it then adopts the width of the iPhone 7+ screen.
Just a note as well the table view doesn't have a fixed width and is pinned to the top, bottom, left and right with 0 spacing and also I'm changing the height of the cells programmatically in code if this could affect it at all as well.
Video: https://drive.google.com/open?id=0B0QLbDLfJn6_YzljUGg4RTUwaTg
Views that come from a xib (or storyboard) have their IB frame values when they are created, before they are added to the view hierarchy. So a case like you describe is probably that something is accessing a view loaded from a xib before it has become part of the layout process and resized.
This would also explain why it's fixed when you go away and come back. The first time, it got the values before they were final, but the second time the values are already final and correct.
Layout code called fromviewDidLoad() for view controllers, or awakeFromNib() or initWith(coder:) for views is the likely cause. Layout code called from viewDidLoad() is especially problematic because it was fine up to iPhone 5s, but would now cause this problem.
It's impossible to say what exactly the issue just from this. From the NSLog statements visible in the video, the issue is whatever code calls that "weather view width". That is being called too early in the layout process. It needs to go in viewWillAppear or viewWillLayoutSubviews to make sure the correct values are ready for whatever calculation is dependent on that. Hope this helps.
I can't seem to recreate this. I would recommend double checking for any updates for Xcode and the Developer tools (softwareupdate --install -a).
Incase you haven't, restart Xcode.
EDIT: Disregard this answer, please read Mike Sand's post.
Try self.view.layoutIfNeeded in viewDidLoad or in viewWillAppear

A popup, "Failed to automatically update constraints" pops up in Xcode 6.3.1

When I added a couple of controls in my viewcontroller in storyboard and click
Resolve Auto Layout Issues -> Reset to Suggested Constraints.
The following popup appears and I cannot perform auto layout constraints.
Though, when I remove the Prototype Cell (which has a couple of labels and an imageview) from my tableview then auto layout works fine. Any thoughts?
Edited:
And manually adding constraints to individual elements work fine as well. After manually setting the image view inside prototype cell, the auto layout has started working fine without popping up that popup. So, maybe, sometime, it is hard for auto layout to figure out all these constraints itself.
Try clearing constraints before resetting them, this has worked for me before.
I had the same problem when using prototype cells in a UITableView and some other views in a UIViewController.
My solution was to select all the elements in the prototype cell and see if these had red or orange markers (constraint conflicts/problems). These elements I cleared the constraints for and afterwards I had no problem telling the entire view to "Reset to Suggested Constraints".
Obviously, Interface Builder has a problem resetting embedded table content constraints.
Actually . If you import different storyboard from another Xcode project. This is not possible to avoid problem. My personal advice is create a new UIViewcontroller or stroyboard. And step by step add items. But. I did not do this.
I lived three times. In fact When I saw this message. I was configuring tableview or UITableviewcell. At the end of the story I have fixed my problem. But There is no gold key for issue. I will explain as much as possible.
for All Views in View Controller select Clear Constraints
If you are using tableview or collection view. please delete.
I assume. there are label, button and scrollview on the project. Please add missing constraints. If you leave problem again. You need to delete any of them.
for All Views in View Controller Reset to Suggested constraints.
If you don't leave problem again. PERFECT. If there is a reverse situation
for All Views in Second View Controller select Clear Constraints
delete any of item. Select add missing constraints again.
Continue to try the third and fourth steps. Until you find the faulty objects.
I'll try to help you if you submit your project.
Good luck .
Following Solution work for me.
Actually initially i used Free-from storyboard of size 600 into 900 that time i was getting this error. so i deleted that storyboard and again drag and drop element and make connections, then i solved issue.
I have faced same problem with Xcode 6. In my MainViewController I have a tableview with custom TableviewCell. In Interface builder itself I have taken taken 2 labels on tableview cell.
When I try to add constraints it gives me error. I did remove prototype cell in tableview and worked with nib with customCell. Be careful while working with custom tableViewCell.
Let me know if you need any additional information.
I had same issue last evening, After many try and error i found that it was just a corrupt ViewController. I created a new ViewController2 with the same aspects, then applied constraints to the ViewController2, and it worked! Still not sure why exactly the other one had issues.
I had some problem with Xcode 7. I solved it very simple. I cleared constraints -
Reset to Suggested Constrains
, then applied -
Add Missing Constrains.
This has worked for me.

Xcode 5, storyboard update image position issues

When I open up my Xcode 4.x project in Xcode 5 and load a Storyboard some strange things are occurring. Mainly, some of my images are getting re-sized and positioned. The size always gets set to 0,0 and the position is somewhere WAY off screen. Values like -3007,12824. This is an app with a massive amount of storyboard layout and while it hasn't messed with all the images, there are easily 500+ that have this problem.
for example this
<rect key="frame" x="403" y="134" width="572" height="486"/>
changed to
<rect key="frame" x="-815" y="1490" width="0.0" height="0.0"/>
I've tried setting the storyboard to Xcode 4.6 version, but no effect. Anyone know why this is happening and how to prevent it (short of manually discarding all the changes I don't want)?
edit: I am using the GM Seed for Xcode 5.
I found this post on the Apple Developer forums which seems to imply this is a bug. I've submitted the appropriate radars to Apple to help the find the root cause (as they've suggested).
In the meantime, I have a simple process for converting my storyboard.
Open them in Xcode 5.
Say I want to commit the changes (we all use source control, right?)
Select each storyboard in the list of modified files, go down the XML diffs and discard any changes which move my images. They are fairly easy to spot.
Add a comment and finish the commit.
After the initial conversion, from 4.x -> 5, Xcode screwed with the location of my images. While it's an annoying process, it's a lot quicker than either re-creating the storyboard or manually trying to move items back to their original position.
Oh yeah... and please file Radars with Apple so they can solve the issue. :)
I encountered this issue as well for some storyboards when I switched between iOS 6 view and iOS 7 view. Only workaround that I have found was to recreate the storyboard from scratch (using XCode 5.)
I had the same problem, after loading an existing Storyboard into Xcode 5, it got automatically updated to the new format, and all the image views were missing.
Turns out the view hierarchies were intact, only the frames were messed up. I went through and fixed all the image view frames, and that fixed the project.
Well, I've found that swapping NSBoxes for NSView fix it and let its contents rest in peace, but...
I have a NSTableCellView with a NSTextField. I set the NSTextField position, clean and build and I do can see my NSTextField in its position. But, if instead of building while I have this NSWindow ON the screen, I build the project while displaying another NSWindow the position of the NSTextField is modified to strange values. Uffff, I don't know what to do next. Any hints?
Got it!!! With XCode 5, if you hide a NSTableColumn and try to modify de NSTableCellView's width, you'll find that x=-0 (?) and width=0. No matter how hard you try to change it. It won´t work. The only way to set the x position and width is to unhide the NSTableColumn, adjust de x and width and then hide it again. It took me a while to get across the solution. I hope that Apple makes something about it.

View Stretched in Storyboard iOS

can anyone tell me how to get my storyboard back to normal? I'm not sure what I did but all my views seem to be stretched and I can't see the navigation bars at the top of them where I need to make changes to buttons I've put up there.
full size screen Shot of Xcode
I do not know the cause, but I had this problem a while back.
In my situation I had a TabBarController pointing to several navigation controllers. To fix the problem I just deleted the TabBarController and replaced it with a new one.
If you have no TabBarController I would try just replacing the first NavigationController where the stretching takes place and it should fix all subsequent View Controllers.
The simplest solution is to roll back with your version control system.
That happened to me too. As Jeremy responses I had a tabBarController but I fixed by deleting the viewControllers associated to the tabBar, 1 of them was the one causing the problem, it was a Navigation controller wich I've changed the title, so the title was a little big and that did the controller to expand.

Resources