UIButton changes position after build - xcode

I encountered a weird problem with a UIView in my Application. I placed some UIButtons, UISlider, etc. on a View. Which looks like this:
However, on the Simulator and on my iPhone it looks like this:
The button "+1 min" is not aligned with the other controls anymore.
The correct x-coordinate is 236. When I inspect the value in the debugger, I get 243.
I already checked the storyboard-file, which has the right value.
Why is it affecting only this button? And more importantly how do I fix this?

If you have used Interface Builder.. Then definitely you have to do changes for autoresize in Interfacebuilder.. Try this it may solve your problem..

Related

View is smaller than the viewcontoller after updating to iPadOS

After updating to Xcode 11 and iPadOS this is how my view looks:
https://imgur.com/a/BqyXyhN
Before the view was filling the whole screen.
When I switch to iPhone layout the issue disappears, but stays on all iPads.
I had the same problem. I verified this began with iOS13. The fix in my case was to change the presentation style of the View Controller from "Automatic" to "Full Screen".
I want to understand better what changed here from 12 to 13, and if this is a proper fix. I'll update with anything else I find.
For context, my View Controller was being presented with a "Show" segue, which is an adaptive segue. So perhaps the adaptivity defaults have changed in iOS13.
You might want to define some constraints for regular width and regular height using size classes.

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

UIViewController leaving Space in bottom

I am upgrading an old project from iOS4 to latest ios8. There are 2 or three view controllers that don't look right, the navigationbar seem to cover portion of the view and also leaving space in the very bottom. I can't seem to figure it out no matter what I changed for settings by removing/adding topbar/statusbars/bottombars, the xib file looks alright, but not when I run it on simulator or device. Here is a screenshot of what it looks like.
If I see this right, it is an UIImageView holding the backgroundimage... ?!?
I can only guess, but you should change the UINavigationBarStyle from translucent to opaque... That will bring everything lower, where it was supposed to be.
Click on this viewController in Storyboard, uncheck the box for "Under Top Bars" and check the box for "Under Bottom Bars" in the Extend Edges Settings. This should solve your problem!

iOS 8 Custom keyboard autolayout issues

I just finished laying out all my buttons for a custom keyboard (xib file) and when I finished adding all the constraints, I didn't have any autolayout issues but when I try to run it either on the simulator or on my 5S, the view isn't the correct size it looks like all of the items in the view sized correctly but the view did not. Is there any way to fix this?
Here is what it's supposed to look like:
Here is what it looks like live:
And in the preview in IB:
Thanks in advance!
Turns out I needed to set the frame of the keyboard view equal to the frame of it's superview
self.keyboardView.frame = self.view.frame;
simple mistake

Put a view in the bottom of another view with a fixed size

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.

Resources