iOS: Portrait & Landsacpe without adjusting programatically - ios

Am creating an screen that supports both landscape & portrait
While am changing the orientation it miss match the design
Is there any way to adjust the screen without adding any code to adjust.
Because am using an dynamic project.
Screenshot: This is the way am set orientation for whole app in plist
Any solution please. Thanks in advance.

You should use Auto Layout feature (from iOS 6.0).
Take a look at:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

You can use Auto Layout if you support iOS 6 and later, or you could simply use the Autoresizing Masks for earlier versions.
Auto Layout allows you to do complex layouts for most scenarios, but in some cases you'll still need to programatically adjust the constraints.
Check this out for more information on how to get started: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html

Related

How to use Safe Area Layout Guide without Autolayout?

I would like to compact my iOS app also in iPhone X. This iOS app developed using autoresizing and deployment target is iOS8.
I had chosen my viewcontroller in storyboard.Then I tried to check Use Safe Area Layout Guide but it automatically appear check mark on Autolayout.Please go through the image.I want to compact iPhone X design of my app without autolayout.How to solve this issue?
You can't use Safe Area Layout without Auto Layout
Look at this Apple Document:
safeAreaLayoutGuide is member/instance of UILayoutGuide class.
And UILayoutGuide: is a rectangular area that can interact with Auto Layout.
So, you must enable auto layout if you want to use Safe Area Insets.
I think, there is no way.
Here is more detail about Safe Area of Xcode 9
Well, I have faced same situation where my old app which was made with Auto Resize thing and need to update with make it compatible for iPhone X, so what I had done so far is to adding splash screen for iPhone X, the following image will give you an idea to how to do this.
After doing that my app now compatible with iPhone X and i have to have add some new condition where design got disrupted. You can try this. hopefully it may help you.
Thanks

Swift layout for different orientations

How can I make different layouts for different orientations on ios?
I try to make an layout in landscape to show 6 picture's in 2 rows.
But in portrait I only will show 4 pictures in 2 rows.
I already have 2 different storyboard for iPad and iPhone.
Can I do this over constrains?
Can I do this with different storyboards like in android?pain
iOS has something called Size Classes. You can use a size class to target a specific device and/or orientation. You can choose the appropriate size class at the bottom of interface builder (wAny hAny) and layout your view accordingly.
https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html
Adding on to #Nitesh's answer: Correct me if I am wrong, I am not very well versed in iOS development as well. I read that it is almost always recommended to use Size Classes while only using one storyboard for all targeted devices. It makes handling issues like screen sizes and orientation much more managable.
In your case, may I suggest using UICollectionView to achieve that effect? It rearranges your tiles based on how much width you have and it supports orientation quite well.

Required to implement Autolayout Constraint and SizeClasses?

I have an iPhone app which should support for iOS 7 to iOS 9(Enhancement) and all the screen sizes as well. Storyboards are enabled Use AutoLayout and Use Size Classes properties. I am not much familiar with using auto layout.
Do I need to add constraints for views to support all the screen sizes? Is there any other ways to achieve that? Launch Images and Icons are enough for all the screen resolutions? will make any problem when iTunes submission?
Yes to it is recommended to run application on all iphone as well as ipad using a single design , use these tutorials it would help
1.) https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/EnablingAdaptiveSizeDesign.html
2.) http://code.tutsplus.com/tutorials/an-introduction-to-adaptive-design--cms-22888

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.

UIWebView content not scaling between different iPhone sizes

So I am working on an iOS app that uses the UIWebView to serve HTML content. Why UIWebView and not WKWebView? well I want this app to work on iOS7 and above. I have just updated my Xcode to Xcode 6.1 and I cannot get my webView to scale to fit the available screen space when changing from the 4 inch screen size to 4.7 and above.
What I am after is to have my app look consistent on all iPhone screen sizes of 4 inch and above as all my HTML5 code that is displayed on the web view is.
In my Attributes inspector I have set the size to iPhone 4-inch and you can see what the app looks like in simulators for iPhones of size 4-inch and 4.7-inch respectively in the link below,
http://imgur.com/gallery/tz7LG/new
How do I get this to scale up appropriately on iPhone screens of different sizes?
fyi, I have set the Scale page to Fit to true for my webView. I am building this app using Swift.
To solve such issue,
1) Uncheck "Use Auto layout" and also disable size classes.
2) Open the size inspector to use Autoresizing as directed in the image below on the desired element (in your case its UIWebView).
Try selecting the bounds as per your requirements.
This will surely solve your problem.
Do check that you haven't coded the dimensions in the .m file.
The answer by Piyush Mathur is simple and seems usable in the given case.
But if the requirements are complex then you need to "Use Auto Layout".
Also make sure that you have set all the needed constraints of the Web-View.
The Introduction to Auto-Layout gives an idea to set constraints to a component which will also give an idea to stretch component (Web-view in your case) based on the device screen size.
You could use Xcode's auto layout tool, which will automatically resize the UIWebView according to the device.
I think the best practice is to untick "constraint to margin" when you add the constraints.
Here are three steps: 1. clear all constraints; 2. add the constraints back in and untick "constrain to margin"; 3. set all four constraints to 0.
Or if you are familiar with the Xcode, this can be done in one step.
What helped me is a creation of 4 constraints:

Resources