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.
Related
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
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.
I just updated to Xcode 7.1 and I noticed that all of the prototype cells in my storyboard tableviews are showing as blank and their elements are missing. Sometimes I can see the prototype cells at the top of the tableview, but when I scroll down to view the others all the cells appear blank and white again.
Has anybody else experienced this and is there a quick fix?
Yes, I'm also experiencing this issue.
As a quick workaround, you can set the View Controller simulated size to Freeform, and make it big enough to accomodate all of your custom cells.
Select View Controller
Change its height
Changing it back to Fixed will revert it to the regular size.
Selecting the Table View and selecting the 'size inspector' icon in the 'utilities' pane and ticking the checkbox 'Preserve SuperView Margins' in the 'view' section seems to reset it.
preserve superview margins
However it's not fixing the problem, it worked fine in previous versions and I agree with #matt to file a bug report with Apple
Edited: Seems they fixed it in 7.1.1
Good morning,
I am new to Xcode and am learning to create iOS applications.
When I open a single view application and click on main.storyboard, my size is w Any h Any. When I decide to add a label and run the iOS simulator (iPhone 6 or iPhone 5S), the label appears somewhere else.
This is really frustrating and I have tried many approaches such as disabling use size classes, changing the storyboard size by clicking the w Any h Any button, and even messing with the constraints as mentioned here: Xcode 6 Storyboard the wrong size?
I am really trying to continue with this but I have seem to hit a wall for a couple of hours now, if someone could shed some light to why I am messing this up, that would be amazing.
EDIT: How can I get it to be a "normal" sized iPhone, such as the iPhone 5s?
You can click on the w Any h Any to change it to a normal iphone size by mousing over the squares and reading which devices they encompass.
You are going to have to use constraints though in order to make anything go where you want it to, I really didn't want to learn them but I couldn't do without them now: they are very useful.
EDIT
Constraints are simple in concept but can be tricky in certain situations:
For any view to have valid constraints that work correctly, it needs to know what the size of the view is and its position in it's "parent container" which is just whatever view or viewController it is inside of.
The little |-O-| shaped button and its neighboring buttons next to "w Any h Any" give you options for positioning and sizing the view. So if you click on a view and then click on that square button in the middle, check the width, height boxes and click the left and top lines in that top positioning thing with sizes in it like so:
Then click on add 4 constraints. You will notice blue lines appear around your view saying that it can properly put it where it needs to go when running the app. If there is any orange or red that means there are conflicting constraints on the view.
Sometimes that can mean you put to many constraints (more than you need) and you just need to delete them in size inspector tab. But more often than not, if that doesn't fix it, I've noticed that I usually have a neighboring view that isn't properly "constrained" and is actually the cause for the other views problems.
How can I get it to be a "normal" sized iPhone, such as the iPhone 5s
You don't. The view controller's main view will be resized correctly when the app runs (on a device or in the simulator), as appropriate for the device type and other aspects of its surroundings.
Your job is to use auto layout so that no matter how the view is resized, its subviews (labels and buttons and so forth) will look good. That is what auto layout is for - it's to help you compensate for the fact that you have no idea what the real size of this view will be at runtime.
Sorry folks if my question seems to be trivial, but xcode drives me crazy.
I don't want anything else, just put a view in the bottom of a view controller in XCode by IB, that has FIXED height even if I rotate device. It stay simply in the bottom and its size stays unchanged.
Autolayout constraints changes its size all the time, hides if I rotate etc. I could not find the settings for this simple problem.
I need this (with fixed size, that does not change/hide when rotating):
How can I do that?
Have you tried unchecking autolayout and playing around with autosizing. Try the below setting . It should work.