I have an SKView that looks great both on a 4in and 3.5in device. The problem is that on the 3.5in device, the bottom part of the view gets cut off (As if attached to the top). How can I have the top (sky) cut off instead? So that the bottom of the SKView is at the bottom of the 3.5in screen's frame.
Thanks!
Update: Here's a screenshot to better explain the situation.
In other words on a 3.5in device the bottom is getting cropped off, but I'd rather have the top cropped off.
Related
I have a horizontal scroll view in place.
Constraints are set to 0 (SuperView) for Scroll View, BackGround, PathView.
Content shows correctly EXCEPT on the left and right ends of scroll, I get this grey space.
I assume it has something to do with Face ID phones having the notch. It doesn't do this on iPhone 8/plus sized phones.
I have also turned off bounce effects and its still there.
Image for reference:
I set up a Launch Screen in xcode with Inferred Size, Simulated Size: Fixed. I put a View in it that covers the whole View Controller. In that View is an image and a label. Both the image and label have height and width constraints, in addition to constraints centering both items with the superview center, yet somehow whenever I run the simulation the label is centered on the screen but the image is off to the right. Anyone know what I need to fix here? Thanks!
Edit: It turns out I had a previous launch screen file listed in Info.plist. I updated it with the new launch screen file name and it worked. I also changed the launch screen to remove the splash.
Use width and height equal to, and align your view horizontally in the container..
Also, as per Apple's human guidelines they advise against having a splash screen.
Workaround of this issue is to not place image vertically centered. You can move image a bit to top or bottom. In such way issue won't be visible.
I am new to Xcode and learning about Autolayout. Having a pretty difficult time and think I've finally hit the wall and really need some guidance on the following.
So I created an image view with a .png background image that show button place holders to help me figure out the exact place I would like to place my button objects. So I pinned the image view on all four sides to 0 and it resized perfectly to different screen sizes. Now the problem came with the button. I dragged the button object out of the Object Library and placed it right on top of the image view, where the button place holder image lies. To the button, I gave constraints to its width and height, pinned the bottom and right, and Aspect Ratio to help resize accordingly to different screen sizes.
The first problem is that although the button is placed exactly where the image view shows, the button is located elsewhere, even though the image view is able to perfectly resize to different screen sizes. The second problem is that, although the button pins fine on all screens, the pinned lengths are staying static and not changing even though the screen goes bigger or smaller. The last problem is that the size of the button in itself is staying static as well even on different screen sizes.
Why is the button not able to resize (used Aspect Ratio but not working) and reposition in relative to different screen sizes? A guidance on this would be really appreciated! Been trying to figure this out for a whole day.
NEW UPDATE WITH TAKING OUT WIDTH AND HEIGHT CONSTRAINTS, LEAVING ASPECT RATIO ALONE:
you should remove that width constraint to let the button resize just leading and trailing spaces are fine to increase it's width in different screen sizes
I have a UIScrollView that contains everything else in my ViewController. I use it because I have logic to scroll up the view when the keyboard shows.
I'm working to make my view compatible with variable screen sizes to accommodate newer iPhones. Currently there are no constraints on anything in the ViewController. If I open the app on a device, it appears in the top left corner.
The first thing I tried was pinning the left/right sides of the UIScrollView to the edges of the container, with left/right distances of 0. When I fired it up on a device, the view had disappeared entirely.
I then tried adding a Horizontal center in container constraint the scrollview (removing the other constraints). Again, just a blank screen - everything had disappeared.
What am I doing wrong? How do I make my scrollview fill the screen, or at least be centered on wider devices?
Is there any way to debug layout issues like this? At the moment, I have no insight into what has happened to the view.
Adding height/width constraints, even though these constraints were overridden to stretch the view to the viewport, fixed this problem.
When the iPad simulator changes orientation the contents of the uiscrollview no longer are aligned to the top. When the app starts in landscape all is well - the controls contained in the scrollview which should be the top most are at the top. The same is true when it starts in portrait.
However, when it is rotated there is a large gap at the top if it was from landscape to portrait or many of those at the top are off the top of screen if it rotates from portrait to landscape.
Does anyone have any ideas what I should be looking at in order to fix this, please?
Thanks
As Rob says - needed to make sure the UIScrollView is anchored top, bottom, left, and right with stretching in vertical and horizontal directions.