How I can use different objects in ViewController to be fullscreen in every iPhone and iPad? - ios

I have a project on Objective C. It has many textfields,buttons,search buttons so it runs cool on iPhone 6, iPhone 6 plus, but on others some objects disappear. Also I make LaunchImage to every iPhone and iPad which I use, but it doesn't help. What can I do?

Every object position is relative to their parent.
So, you need to use autolayout to adjust your elements in different resolutions.
You can check Apple's guide about it:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
Also this useful tutorial:
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

Related

is it possible to design view for iPad without autolayout?

I have developed app without autolayout for iPhone. Now I need that app for iPad also. Is it possible to create it without autolayout?
yes, you have to create App directly then select iPad.
and using Auto Resize ,you can directly develop app for iPad only.
I have attached few Screen shot, may be helpful to you.
Create new project, using XIB .
I don't recommend that (see comment of #Nimit Parekh).
You can use Sized classes to avoid having 2 separate Storyboards - one for iPhone and other for iPad. There is a good tutorial.
Second option is to have 2 storyboards. You only need to link all outlets from the 1st storyboard to the second. You have to check not to miss something, otherwise you can get exceptions in iPad.
The 3rd option is manually (from the code) to manage layout for iPad - but this will create a lot of specific code for iPad only (you have to check what type is your device and split code) - this is not recommended.
Take into account that Autolayout is more easy to apply on iPad (from my point of view) because of equal withd / height ratio for iPad - it is the same up to now. Not like in iPhone.

Autolayout(xcode 6,swift)

In I phone 5s simulator its working fine! I have one label,one image view and one button.As you can click on the link and see the picture now so i tell you that I used my image view as a background and the label is in the middle and the button is in the lower middle so i want that to look same in all the devices. i don't know anything about constraints.I am using Xcode 6
https://drive.google.com/file/d/0B2z_d4wEKPEFLV9RNFVlR3A5SFppa0tJT2tiQkQwVVVVTDVz/view?usp=sharing
I suggest you to take a look at this youtube tutorial. I learned how to make the constrains by watching it. The tutorial teaches how to make the similar layout as you required.
Link: https://www.youtube.com/watch?v=RpMzEmF-xZM
Hope this is helpful~
Autolayout is the tool used to make UI look similar across all devices, you should try to learn it if you want to continue to develop IOS apps. The concepts are pretty basic and are used throughout other languages.
This tutorial is useful if you want to create the auto layout using storyboards.
This tutorial is useful if you are making the view programmatically. I tend to use code for auto layout but it is just a preference, storyboards is fairly simple so I would suggest that. If you are going to do it in code a is to forget setting the autoresizing mask into constraints to false. You have to set this property on all the views you want to use auto layout for.
view2.setTranslatesAutoresizingMaskIntoConstraints(false)
Background ImageView
Select Image ->Pin->Uncheck Constraints to margin-> select top,bottom,left,right.
Button
Select Button-> Pin->Uncheck Constraints to margin->select bottom,left,right,Height.
label
Select label->Align->Center horizontally and Center Vertically in Container.
Pin->Width,Height.
If it is working for iPhone 5 but not another layout then this is probably happening.
There are demensions in the centre of the lower tab bar of story boards
There are screen size settings in the story board and regular*regular is the only one that is universal to all orientations and sizes of the ios device. if you set constraints while viewing in regular by compact (landscape for 5.5 inch iPhone) then those constraints will only be apply to 5.5 inch iPhones in landscape and if you tried running on a smaller iPod it would be as if you never set the constraints. the constraints for the 5.5 inch iPhone would not apply to the small iPod
if constraints were made in compact by compact and you were viewing the story board in say regular by compact then you would get an error saying that things are misplace and will not appear in the same at runtime. view the storyboard in the same dimensions that you set the constraints and you should not have an issue.
There is an option to simulate the device you want to run on specifically in storyboard and it can be say only 5.5 inch iPhones or something, whatever device.
go to paul hegarty developing iOS apps with swift on iTunes you if you want to learn more. He is a good source.

UITextfield Custom Position moved up because of different iPhone sizes

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

How to support one xib for all iPhone devices upto iPhone 6 Plus?

I started one new iOS apllication. And that application requirement is app should support from iPhone 4 to iPhone 6 Plus. I am very much familiar with using Xib files. So far I differentiated my apps with iPhone 5 and below iPhone 5. For that I Used 2 Xib files for one is for iPhone 5 and other is iPhone 5 below according to device height I added like that. But now apple has relased iPhone 6 and iPhone 6 Plus with iOS 8 along with XCode 6. For these 4 types devices,
1) iPhone 4 2) iPhone 5 3) iPhone 6 and 4) iPhone 6 Plus do I need to add 4 Xibs or any other solution.
To learn Storyboards, now I don't have that much time because my app has already release date confirmed from Client. But I will learn about sotryboard in future definately.
I have tried with Autolayout concept, but its not worked for me. and I dont have full awarness on Autolayout concept also. Yesterday I started my new project with XCode 6, So I taken iPhone 6 view and tried to use autoresizing and autolayout but not worked for me and views are overlapping. I know for different devices creating different xibs is not good practice. For creating each device with each xib would take huge time. I am really bothering about this how to handle different devices from yesterday onwards. Please somebody help me to came out from this issue. Really highly thankful to you. If anything mistakes in my content please forgive me.
Your question deserves a longer answer than StackOverflow can provide, but there are a few pointers I can give you.
For each of your xibs, enable Size Classes and Autolayout.
Set each xib root view's size class to width Any and height Any, which I believe are the defaults.
Design your interface in a way that looks decent on this theoretical Any x Any device.
I highly recommend using a UIScrollView at the top level of any view controller's view hierarchy.
Use constraints to anchor the controls. I find it easiest to start with the control in the top left corner, anchor it to the containing view's top and left sides, and then work your way down and across until all of your controls are constrained on all 4 sides, or on one vertical and one horizontal size, along with explicit height and width. Be generous with the greater-than and less-than relationships in your constraints.
To customize for each device layout, switch the size class to the desired combination. Note that any constraints you add, change, or remove, as well as any controls that you add or remove, will be changed only for the current class size. Do this for each different size class that you're going to support. See Apple's reference for which size classes are used for each device.
Test your layouts using the Resizable Device simulators.
This is hard work, but it sure beats having to maintain a different xib for each device size.

iPhone 6 App Resizing

So I recently got my iPhone 6, and I was working on a project earlier. When the new device arrived, the application looked messed up. For example, I have UIWebViews on the app, and when loaded on the iPhone 6, it just appears as if it where the iPhone 5s screen with white around.
Please help!
Xcode has an auto layout tool that allows you to add constraints to the objects that you add to your story board so that in the event of the app being displayed on a different screen size, it has the logic to intelligently place your objects and lay them out to fit the new screen size.
I'd start here: https://developer.apple.com/library/IOs/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
...but there's a wealth of good tutorials and youtube videos out there showing examples of good practice.

Resources