Xcode UIToolbar Autoresize - ios

I have an iPhone application that runs perfectly on the iPhone 4s but when run on an iPhone 5 some parts of the screen doesn't autoresize. The thing that isn't resizing is the UIToolbar. My application always runs in Landscape mode, so the toolbar is at the bottom of the screen and these are the dimensions of the toolbar:
X: 0 Y: 256
Width: 480 Height: 44
I've tried adjusting the auto-resizing tool to almost every combination and nothing works. I can get the toolbar to spread across the screen, but the 3 buttons stay the same size. Each button is of width = 148. Is there an easier way to have the entire application just automatically resize correctly? For some reason my iPhone app worked great on the iPad when you used the "x2" resize view. Thoughts?

so the OP uses stock items and they don't resize then!
I would add flexible spacer items in between each button -- they resize

To solve my problem I just used IBOutlets that connected to each barbutton and if the screen size was for the iPhone 5, the width would adjust accordingly for each screen, if regular screen (iPhone 4s and below); then stay the same. Not a very efficient way but it worked for me.

Take a look at the images and select the autosizing red lines, if you select the bottom line it will keep on the bottom always, and if you select top and bottom it will stay at the same place. So verify your UIToolBar autosizing properties.
EDIT
EDIT2
Check out this answer How to detect iPhone 5 if you can't autosize, one quick solution that occurs mi if to change the frame in the code. Check if the device is a iPhone 5 or 4S to give a specific frame so you can adjut the width.

Related

How to adjust a header component's height automatically based on which device the app is running on in Swift

A header component in my app is just a simple UIView with a title and a bottom border and the height of it is 64, it looks like this on any other devices except for iPhone X:
However, on an iPhone X device, it looks like this:
How do I automatically make the height of the header larger when the app is running on an iPhone X device but remain 64 on any other devices like this?
A couple of points to help you get into the right direction:
Do you have a solid reason NOT to use a UINavigationController?
This would give you a navigation bar + navigation title for free without having to care about it.
If so, use Safe Layout Guide
With the arrival of the iPhone X, apple introduced the concept of "Safe Area". For every iPhone except the iPhone X, it returns the top-most view bounds, but for the iPhone X it returns a rectangle that stops at the rounded corners.
In order to fix your issue, you should constraint your view's top to the top of the safe area, instead of the top layout guide.

Keep single storyboard for iPhone and iPad

I am creating a demo project for keeping single storyboard for both iPad and iPhone devices. I am going to use Xcode 8 first time.
I created a button and put this button in center of the View with using constraints. I successfully managed the width and height of the button according to the device. On iPhone width is 100 and height is 50. And on iPad width is 200 and height is 100. To achieve this I used "Vary for Traits".
So I just want to know, am I on correct flow, I mean, to achieve size classes "Vary for Traits" is the correct ways OR is there any other way to achieve this?

Constrains look different on my iPhone 5S

This is my first post. I just started coding. I want to make my first simple app. I own an iPhone 5S and when I add constrains in compact width / compact width & regular height(in XCode), it shows it right on the iPhone 6S plus simulator. When I try it on my iPhone it just looks weird. I know the sizes of the iPhones are different, but how can I correct this? Now, if I code in compact width / compact width & regular height, it feels like I am coding for an iPhone 6...
I hope someone can help me.
Here is the Storyboard:
I use compact/regular size classes for portrait, and any/compact for landscape, for those two phones you mention (actually, for all of the phones).
And, (squinting at your constraints in the tiny pic), it looks to me like the constraints are "wrong" (not optimal, at least). You've got the button pinned 550 down and 280 across from the edges, which won't look right for smaller devices.
Try aligning the button to horiz and vertical centers, and it will look right everywhere.
Or pin ONE of the edges of the button, and ONE of the top/bottom edges of the button, to the layout margins on one corner. Then it will look right on all devices.
Instead of removing the trailing and bottom constraints, as #Kevin suggests, set both of their constants to 0 (or whatever's reasonable), and make them greater than or equal, not equal.
For the constraints to appear fine for different screen sizes, one possible way is to add the required constraints to your button or label or any other component and have a preview look at it in the assistant editor section.(Click on assistant editor and in the split screen that comes up, find the Automatic section and within it the preview option)This helps to view the layout of your app for different screen sizes. This helps to manage your auto layout issues by a good extent.

How to properly size an object using constraints in Xcode 6?

I'm fairly new to Xcode and I am trying to create a simple app that is universal to support all iPhone screen sizes.
I'm testing this on an iPhone 5 screen and iPhone 6 screen.
I have the following constraints for the background UIImageView object, which expands to support both screen sizes perfectly.
For the View object colored in gray, I set the following constraints:
However, when I tested it on my iPhone 5 and iPhone 6, the View object remains the same size. It doesn't resize proportionate to both phone screen sizes because you can see how much space the View object takes as shown:
Is there any way to fix this?
Thanks!
For Gray view, besides CEnterX & CenterY, you need to define height constraints and Leading space and Trailing zero with 0 constant.

ImageView width more than cell width in UITableView Cell - XCode 6

I am developing an application in XCode 6 for iOS 8. I am not using auto-layout. I am trying to put an ImageView in a UITableView cell. When i run the app on iPhone 6/6 Plus:
The size of the imageView becomes double than my cell size if i check all the auto-resizing options.
The size of the imageView becomes lesser in width if i uncheck all resizing options except for the left one.
Is this some bug in XCode? Because I think, if i check all the auto-resizing options, and use scale to fill for the imageView, it should scale up and down accordingly, rather than going out of bounds of the view and cell.
All help is appreciated.
I ended up finding out that it all depends upon the splash screens you have added. AutoResizing proves troublesome on iPhone 6 and 6+ if you have splash screens for them.
But if you remove those splash screens and only keep a splash screen for iPhone 5, then your app will properly scale up and down, hence the bug will be resolved.

Resources