Ok, so I have multiple views on one of my screens. UIButtons, UIImageViews, UIViews, and a Container View.
Anytime I go to resize a view, it seems that one view will be auto resized to 0. When I resize via the actual inspector, no issues. It is just manual resizing on the storyboard itself.
I am not sure what is going on, has anyone experienced this?
>Check a video here<
Thanks in advance.
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 have been running into some issues where my UITableView after being dragged and dropped into my view controller appears with a sizable white space gap from the top of the element ot the start of the prototype cells. Why does this occur by default and is there a way to remove this? Maybe in the size inspector?
I was having the same issue in 6.3.2 and all I had to do was to go to the ViewController's attribute inspector and uncheck the "Adjust Scroll View Insets" in the layout information section.
Sorry, they won't let me post images, but that solved the frustration for me. Hope it helps someone else.
I'm converting an app that I made for iPhone to be used on iPad. Using constraints on the Xcode 6 storyboard is killing me right now.
With my rep score I can't post an image of what I'm getting, but basically even when I set the constraints and the placement of the object (a UIView) on a storyboard sized for iPad, all the objects on the viewController fill only the top/left area of the screen.
What's the best way to handle this?
-- when you change size of view, other view will be auto change to {0,0,0,0}, isn't ?
but it doesn't change in the right panel.
it is your storeboard files some settings have some wrong.
Demo test link http://www.cocoachina.com/bbs/job.php?action=download&aid=80409
Check for those points:
hope this can help you.
Occasionally in my iPad Master/Detail app the Master View slides into view at a full-screen width rather than its usual 320p width. This happens under ios 5 and 6 on iPads 1 and 2. When it happens the view functions normally and the Master view continually reappears at full screen width until the app is restarted. Table view cells are also stretched to full-screen and so they look strange. I have not been able to characterize this except that it may happen only after I have received a memory warning.
There is no place in my code where I try to change the width (or anything else) of the Master view. Has this been seen or reported? I've found no mention of it in my searches. Thx
Do you use Interface Builder to create the views? If so try modifying "Autoresize subviews" attribute in the "Attributes Inspector" of the view
In my application i am adding views to a window and i am setting windows size correctly to fit the views.But when i am trying to resize the windows the views in the window the views are not getting fitted depending on the window size one view gets overlapped with the other one and mismatchings. Can any one help me in this isssue by posting some sample how to do it.
i am new to mac development and got strucked up in this issue.
Thanks in advance
NSView has a setAutoresizingMask: method where you can specify how the view should resize, when its parent view changes size.
You can set this in code, but it might be easier to use Interface Builder.