Adapting UIButton sizes to iphone 6 and 6 plus - ios

I am a little lost here.
Consider in a landscape mode I have 3 UIButtons which are of equal widths aligned next to each other with a gap and the occupy the entire space of the screen. These buttons were added programatically with fixed button sizes.
All looks fine and nice in a iPhone4s screen. Now comes the iphone6+. The way I am determining the button sizes is
buttonWidth = 21.f * [[UIScreen mainScreen] scale];
And then the button seems to fit good for the iPhone 6+ screen and covers the full area.
Will it work for iPhone 6 as well ?
Is this the right approach? How do i determine different sizes for the buttons for different screen sizes? Yes, I know adaptive layout, but we still have to specify the button sizes, dont we?
Help would be great appreciated.

Related

How to make circles stay circles and resize on different screen sizes?

I really need help, I made an app I designed everything for iphone 7 I designed it with constraints and now I am having a problem because they don't look right on SE or 4s.
I am using circles made with IBDesignables(using cornerRadius to make circles). I want them when it resizes to stay circles because I tried couple of things and when it resizes its not a circle anymore.
Sorry for the long paragraph I just really need a tip !
How can I solve this problem
Here is how it looks on Iphone 7
Here is how it looks on Iphone SE
Here is how it looks on Iphone 4s
If you want to keep that all view stay circle for all device you must keep their height and width same.
You can easily do this thing with Autolayout set Aspect ratio of that view is 1 so their height and width remain same check screen shot

Content is being cut

Why is it cutting the sides off? It looks perfectly fine in storyboard. I set the size to 4.7 inch iPhone and applied the necessary constraints, but this happens.
Sounds silly, but make sure you have the correct resolution of splash screens set up. On certain phones I've noticed that the incorrect size would clip the screen to the size of the splash screen. Apple is your friend it just werks and all that.
So it's a duplicate of this Why [UIScreen mainScreen].bounds] is not returning full screen size?

iPad app displaying iPhone screen size

I am working on an app and it has 3 storyboards - iPad, iPhone and iPhone 4. 3 different users (myself included) have had the experience where on their iPad - the splash screen that loads is small and in the top-left corner...leaving much white space to the right and bottom.
It is as if it is loading the iPhone size splash.
I have no launch screen file selected in the general tab of the project. I have also noticed that after restarting my iPad, it does seem to load the proper screen size. Any ideas as to what is going on?
Use this line of code for screen size.
CGRect screen_size = [[UIScreen mainScreen]bounds];

Developing for IPhone 4s, 5, 6 and 6+

I've been working on a specific app for a while now and everything was good. But upon all this news of the iPhone 6 and the new Xcode, everything has just become confusing. Using Auto layout and designing for the iPhone have just become the most complicated thing to do. Every time I add constraints my images just triple in size. When all I want is to resize them to fit rationally across all the iPhone platforms(In portrait mode). For example I would like for certain images to grow as I work From the iPhone 5 to the 6+. Does any one know how to do this?
What do you mean triple in size?
Easiest way to have an image view scale is do the following:
Add it as a subview to the view of your view controller
Pin it at the top, left and right, leaving height unconstrained
Add an aspect ratio constraint, so that it can automatically calculate its height based on the width it gets

ioS change button images to fill up the screen for iphone 3.5 inch and iphone 4 inch

I've just started writing iOs apps for work and I came across this problem which has to do with resizing my buttons on a screen to suit both the iPhone 3.5 inch and 4 inch. If you look at the screenshots below you will probably get the majority of what I am trying to solve.
So our designer has designed the layout whereby as you can see the colour buttons are supposed to fill the height of the screen for both iphone sets of devices, minus the height of the stautus bar and the navigation bar of the app.
I've had a look around a liitle bit about auto-resize, however I don't feel it is suitable for the requirements as you can see in the image.
Another approach that I thought about was in code, I would write an if statement, to determine if the person using the app was on the iphone 4 inch then load different images. However upon thinking about it more detail I would have to change the position for each of those buttons to ensure that the newly loaded images to prevent overlapping.
My question would be is there a way to change the position of the buttons in objective c to achieve what I want according to the screenshots?
Also it would be greatly appreciated if you can tell me if I am on the right track on the approach of my current problem.
Thanks heaps.
If you don't want to use AutoLayout, then I would advise turning it off in Interface Builder so you can control the frames manually. As for controlling the frames, make sure each of your views that you want to edit is accessible to your code (either its an IBOutlet or you manually instantiate it) and then adjust the myView.frame property. myView.frame is a CGRect, so you can edit it like this: myView.frame = CGRectMake(x, y, width, height).

Resources