optimizing my app to iPhone 3.5 inch screens - ios

I have made an app and it works really great on iPhone simulator 4 inch screen.
But, when I run it on the iPhone 3.5 inch screen, it cuts the bottom of my app
How can I optimize my app to the 3.5 inch screens?
(note :I am using storyboards)

Open your storyboard, then select one of the view controllers. Change the size of the screen to 3.5" as shown here:
Make sure your views are laid out correctly. You may either use Auto Layout or, if you're not using it, check the view sizes, and the springs and struts:
Here, you want to make sure that you don't hardcode the view height to 4", or doing anything similar. After you make the fixes, you can switch back to the 4" size, to make sure the views are still laid out. Repeat for all your view controllers in your storyboard, until done.
If your code updates the UI (e.g. by adding/positioning/animating views), you also need to make sure you're not hardcoding any view's frame with the assumption that the screen is 4".

First option is to use autolayouts.
Second option is to set your views scale properly.
by clicking on a button i selected, you can see how will your layout look on different screen sizes
Now, you select a view you want to set-up, and play with this option here, marked on the picture below

Related

Different designs for different devices ios

I have been creating an application for iPhone and iPad. I am using Auto Layout (wAny and hAny). Now I want a separate design for iPhone 4s alone. How can I use separate designs for this device. I already completed most of the designs with this wAny and hAny. How can I change this.
Edit:
I want to change only few view controller not all the designs.
I suggest not to go with different storyboards. You can add 2 views inside that viewcontroller's(for which the design is different) view and toggle it programmatically depending on the device. Regarding autolayout, set wAny and hAny and add constraints accordingly.
VC.view
-iPhone 4 View
-Other device's view
This can be done in storyboard only.
So programmatically when loading the vc, check the device and show the specific view hiding the other view. In this case in future, even if the design is normalized, you can easily use the same view with change in one line of code.
This is necessary if the design is totally different. Or if it's just few sub views which are different, I think you should write some code to hide and unhide the subviews acc to the device.
I am a novice in iOS, please correct me if I am wrong anywhere.
Better to go with design it as separate controls if you have design changes and load it conditionally for 3.5 inch screens . If its a simple changes (easily managed through codes) then go with codes itself.

Default size classes seem to only work for iPad (XCode 6)

I am trying to wrap my head around the new size classes in iOS8 and XCode6. I am attempting to create a nib, without a storyboard, and do something really simple--center a UIView on the screen.
Starting with a nib in the default size: w:Regular h:Regular, I place a 200x200 UIView onto the parent view and center it, then add contraints to pin it. In my preview pane, the UIView only shows up on the iPad view.
I need for this view to show up on iPads in lanscape and iPhones in portrait. I suppose some day i will understand why Apple thinks this is so much easier, but at the moment I'm bewildered.
When I switch my design view to any of the iPhone supported modes, the UIView disappears.
Even when I unpin the UIView and move it around in the design view, it never shows up in the iPhone view. In other words, I've tried everything to get this view to appear on an iPhone and nothing works.
Here is my UIView and settings:
Obviously there is something I'm missing, but I'm getting really frustrated trying to figure it out. Can anyone offer a clue? Thanks!
It's because you defined your view only for the size classes Regular & Regular. For them to show up on the iPhone you will have to configure the view also for the appropriate size classes, which in case of the iPhone is Regular & Compact where (<height> & <width>).
UPDATE:
The views generally only show up in the size classes for which they are configured. You currently have Regular & Regular selected, this can be seen from your screenshot. This means you defined it only for the devices with size classes Regular & Regular, which is the iPad in both orientations.
You need to add the views also in the size class that you are targeting, which are the size classes of the iPhone.

UIViewController, Auto Layout and iPhone 6

We are updating our Auto Layout-using app to natively support iPhone 6 resolution. We added the iPhone 6 launch image, and most of the views scaled nicely.
However, we are experiencing a small annoyance: when loading new view controllers, the views have the iPhone 5 resolution on the UIViewController's viewDidLoad method. The view only gets the iPhone 6 resolution when you hit viewWillAppear.
Why is this? Is there anything we can configure or modify to make the views have the final resolution on viewDidLoad already?
I think the right place to get geometry data from your views is in the method:
- (void)viewDidLayoutSubviews;
This is called when auto layout finishes laying the views. Please beware this method can be called multiple times, i.e. after a rotation of the device.
EDIT
In interface builder, there is an option to set the size for the simulated metrics. I'm not sure if this has to do only with what interface builder displays, or also with the frame of the view at load time. Maybe you can change it and give it a try.

Using same ViewController files for 2 Storyboards (to get identical views)

I am building my first single view app. I have my UI elements in my main storyboard. I arranged all of my elements based on the 3.5inch screen and now it looks good. I want the app looks good on 4-inch display as well. And now I created a 4-inch storyboard (blank) and I want to have similar views with exactly the same outlets shown, just change the layouts and positions to fit the 4 inch screen.
I thought I could create a separate storyboard view for different layout but use the same view controller files (.h and .m) so everything (the buttons and labels, etc.) works in the same way but I don't know to do it. Is this a correct idea and if yes how to accomplish it?
Of course, you can... But there is no need for that! You should be interested in autolayout.
Here is a two-part tutorial on how to do that.
Of course you can use the same classes for other Storyboard. This is exactly what you do when you're developing Universal application. But in this case you'll have to put some assumptions in your code for determining whether you're using 4 inch or 3.5 inch screen. Preprocessor instructions will be helpful for you.
There are many ways to achieve your main objective:
having only one storyboard item with autolayouts that will auto
adjust the screen for 3.5/4 inch
if you don't like autolayout and the view it's not to complicated, the "springs and struts" can achieve as well auto resize.
you can have both 3.5 and 4 inch view controllers in the same storyboard, access one or the other with "self.storyboard instantiateviewcontrollerwithidentifier"
you can have as many storyboards as you like and do UIStoryboard *storybord = [UIStoryboard storyboardWithName..
PS: I'm a fan of option 2. It's usually worth to have 2 storyboards when the app is universal, so you'll have one fore iPhone and one for iPad.

Developing on an iPod iTouch - UIView Issues

So I've been using this site for a lot of my questions. I'm very good with Googling problems and debugging even the worst error code, but this is something rather basic that I'm not able to figure out.
My UIView compared to what I actually see on the iTouch has always been a bit different. I'm not sure if this is xCode's IB just having larger graphics for its buttons, but in general there is this 20px height difference, to the point where if I set a button at the bottom of the UIView, it gets cut off. (I thought it was supposed to be 320x460..)
Normally I shrug this off because it hasn't been an issue till I've started to put scrolling into place with the login screen. xCode claims my view is 320x548, my app says its 320x480. If I resize my scroll size to 320x480, the view shrinks on the iTouch, leaving a large gap.
I have been using UIViews in the IB rather then a ViewController because I'm subviewing mixed with some nav control.
Is there something that I'm doing wrong?
http://oi49.tinypic.com/rrnjit.jpg (when first loading)
http://oi50.tinypic.com/j8matu.jpg (scrolling down about 20 px..)
You need to make correct use of springs and struts or Auto Layout. You are probably designing your app for the 4 inch screen - in your Storyboard, there is an option to see how it would look on a 3:5 inch screen. Press that.
For more info, Google Auto Layout.

Resources