I've got a weird issue with Unity, where the height of the screen doesn't match the layout built in the editor, but only on iOS. It does work in the editor, in a Windows standalone and in the Android app, but not on iOS (im testing on an iPhone 5).
So the menu layout can be broken down to just a couple of full width images with different y-positions. These images are set to stretch in height, so no matter how I change the play-preview in the editor, they always fill the screen as intended.
As soon as I test it on the iPhone however, it looks like there was height added to the screen after calculating all the image heights or something. Every image seems to be about 10% too short.
This all did work some weeks ago, when I was on an older iOS version, xcode version and Unity version, but I updated them all in the meantime, so I can't say which one could be the cause for this.
Some weeks ago, the minimum iOS version in Unity was set to 7.0, now it has to be at least 8.0 to not get the "update project settings" warning in xcode.
The roughly 10% could be the iOS status bar, which could be taken into account for the height calculations, but then turned off and the game can span over the whole height.
The iOS "Resolution and Presentation" settings are set to require fullscreen and hide status bar.
Edit:
Here's what it looks like in the editor and on iOS.
The 4 different canvas have just different settings for the canvas scaler. The images in all of them have their RectTransform set to stretch in both directions.
It turned out to be caused by the generation of mipmaps.
I don't know why this is the cause and I don't know, why it's only a problem on iOS, but not on any other common platform, but once I used an image that had mipmaps disabled, it worked.
It then also worked on the original images, once I deactivated the mipmaps there.
I guess it has someting to do with the gradient images being 1x1920, so mipmaps make little sense. I'm wondering, why this is making the height buggy and not the width.
Related
I am 2 days into iOS app development, I am quite new. The very first thing I wanted to implement in my app is a Launch Screen using Storyboards (I heard there are other ways but I found this the easier). I have a vector-based PDF file (image) because I wanted to implement a gradient background without a loss in quality that supports all device resolutions.
I created an Image View in the Interface-Builder (IB) but it does not automatically stretch vertically and horizontally to fill the device length.
I simulate my results on an iPhone 14, only thin white margins appear, but on a large iPad, the majority of the screen is white. It's like as if the the image resolution is fixed across all devices.
No matter what resizing I try, I can't get it to work.
I come from an Android app development background so something like this is very easy to implement (we have fill_parent / match_parent to stress the view to its containing parent view dimensions). Is such a behavior possible on iOS ?
You have to apply constraint on the image in launch screen.
I am new to Swift and I am still struggling to find an easy way to make sure that my UI will scale properly based on screen size.
My UI is made of few buttons and labels and it was built on a iPhone 8 Plus screen. But now when I run it on smaller or bigger devices, the button are either not entirely visible or not centered.
How can I make sure that what I see on the iPhone 8 Plus is being scaled correctly to other devices? Any example I can follow?
I am using Xcode 12 and latest Swift version.
Hi I'm new to Xcode and I have been checking out ObjC tutorials lately and I started playing around with the storyboard.
So What I did was:
Drag some buttons/labels onto a view in storyboard
Set the size & position using the size inspector
Build and preview the app on the iPad
It looked fine at the beginning, but then I noticed that the position and size of the buttons/labels kept changing over time (by like a few pixels) as I built the project for a number of times.
I have not change (or set) anything about insets/constraints yet.
Can anyone please advise as I dont think anyone would be happy for changing the position & size when there is over 100+ UI elements.
The thing is that you have created the layout for one pixel density and implement on different pixel density. Which means you to exactly see what you are making build the layout in also ipad (you can change it in the storyboard see below).
I have an iPad app that I'm converting to a universal app to show on phones. It has both a tab bar and a navigation bar, and my problem is that they are both way too big on the phone. I could swear I heard Paul Hegarty (from the iTunes U class from Stanford on Swift app development) mention a switch or trick somewhere that would cause the bars to adapt to the iPhone, but I can't find it.
Here are screenshots of my apps bars, vs the Photos app in the iPhone 6 simulator to show what I'm talking about.
Not a huge difference, but significant on a small phone screen.
My fonts are also way to big, which is confusing since I have them set to the system "headline" or "body" options for all size classes, but that may be a separate issue.
Any help is greatly appreciated!
App written in Swift, using storyboards for iOS8, btw.
Edit:
The more I look at this, the more I'm convinced it's not related to the bars, but the entire app - the fonts and everything. The whole app appears to be zoomed in to 120%, which is subtle, but looks really bad and wastes space.
I have also now seen this in a second app - the Apple DateCell sample. It also appears 'zoomed in' when run on the iPhone 6 simulator.
Edit 2:
This effect is even more exaggerated on the iPhone 6 Plus simulator - everything is even more 'zoomed in' looking - the top and bottom bars are almost twice the height they should be. This can be seen by downloading the Apple DateCell sample and running it.
Edit 3:
ARGGGG, all this time wasted, and it was due to the launch screen image - why on earth would a launch screen image not being set cause the entire app to scale?
I finally figured this out - it was related to the launch screen image. Apparently if it's not setup right, the whole app scales on the iPhone 6 and 6 Plus for some reason. This question is what pointed me to the answer.
For me, I had to both create a LaunchScreen image in Assets, and set it in the project file, and ALSO select the launchScreen.xib as the Launch Screen File in the project. I don't have a real launch screen yet, so these are both just empty or defaults in my case.
I have several custom UITextfields in my app. I started this app on Xcode 5 and ran on iphone 5 simulator. After Xcode updated to Xcode 6, I ran the app on iPhone 6 simulator. Now all the textfield positions moved up because of large screen size. I just wanted to know is there anything I could do so that the positions of textfields automatically get adjusted depending upon the iPhone models.
You need to rebuild your interface to handle the different screen sizes. In particular, you need to work with the AutoLayout feature to help determine how you want everything to scale/move/position based on multiple screen sizes. This can be done via the Storyboard (easier but sometimes frustrating) or in code (harder at first but more control later). I usually use Storyboards and it's worked great on several projects.
Do you want it centered and respecting your original layout and margins? a certain distance from the top or sides? everything scaled up appropriately? All these things can be done with AutoLayouts.
Check out the great tutorial here for more information:
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1