Can Auto Layout work only for one particular screen? - ios

Here is the thing: I got a task to update current iOS App, which is quite old. All UI is made in xib's or frames, there are no constraints.
I have remade one screen totally on constraints, but nothing really happened. The app still looks stretched on iPhone 6/6+.
So what should I do to make adaptive UI work?

Yeah, you can, just turn on autolayout in the inspector in the right panel:

Your app may be auto-scaled by OS system. You should add LaunchScreen for it to support iPhone 4.7, iPhone 5.5 inch
http://oleb.net/blog/2014/08/replacing-launch-images-with-storyboards/

Related

Xcode 8 AutoLayout/Constraints: Changing view to fit each Iphone screen size?

I am new to Xcode, and have been trying to figure out how to use AutoLayout and constraints. Long story short, after I hit 'add missing constraints' the Iphone 7 screen looks just as I intended, but both the Iphone 7 plus and Iphone SE screens look completely screwed up. What can I do to fix this so that every screen looks like the Iphone 7?
Iphone 7
Example Iphone SE (screwed up)
add missing constrains option means: adds the constraints needed to have a nonambiguous layout. may not work well for all iOS devices, and may not work well for device's rotation changes or view size changes, so, check view's constrains in size inspector panel
for more info:check Apple's auto layout guide

Views in storyboard do not resize properly on iPhone 6

I've checked a lot of different websites and stackoverflow answers, and I'm still stuck.
I developed an app for iPhone and iPad targeting iOS 7.1. I have two storyboards, one for each device. The app only displays in portrait mode. I cannot seem to get the app to display full screen on the iPhone 6 simulator.
I've tried numerous things, I followed the advice linked here by adding a Launch Screen, setting the iPhone storyboard to auto layout and "use size classes", and . Not only does that not affect the size, but the Launch Screen doesn't seem to scale properly either. If I get it to fit the iPhone 6 it doesn't fit the iPhone 5 properly.
I've tried adding the proper launch images and I don't get any errors saying the wrong image resolution is present.
I've used the storyboard as a Launch Screen described here.
Now, when I switched to "use size classes" I could manually extend the objects in the views to match up with the size of iPhone 6 (I have not tested it for 6s) but that makes it extend past the iPhone 5 boundaries. The only thing I can think of right now is to create another storyboard and detect if it's iPhone 6, but I would really like some other ideas.
Here's what it looks like for iPhone 6:
And here's what it looks like on iPhone 5:
Best advice i can give u is
Use default size class , the classic 600x600 and then use Auto Layout
Or do the reverse, take a 3.5inch size VC and apply Auto Layout on it. Everything will present itself quite perfectly if you can apply the right constraints
Here is a link for an awesome Autolayout tutorial

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.

Black Frame Around iPad Build

I made an iPhone app under universal applications. Deleted the iPad storyboard at the start and added it back in using this answer: Converting Storyboard from iPhone to iPad at a later stage.
Now when I run my iPad build, there seems to be a black border around it.
I've made sure my .plist is using Main_iPad for Main storyboard file base name (iPad).
Found my bug: this is because under Deployment Info in the General tab, I selected only iPhone as my Devices. Changing it to Universal fixed it.
Frankly speaking, this looks like just a scaled-up version of iPhone app. Anyways, to make it work in a better shape you may have to tweak here :
Make sure you have added constraints that actually meeting the iPad size requirements as well. The width & the Heights.
Please provide a launchImage for iPad size. That should solve your problem.
Hope that helps.

Fit an iOS application developed for 4 inch screen to 3.5 inch screen

I am writing my first iOS app and just realized a serious problem. I was using storyboard for a 4 inch iphone screen and forgot to take 3.5 inch screens into consideration. :( It seems that this could be relatively fixed easily if I have done everything in code. But unfortunately, I have used storyboard for some parts of my app. It seems that the table views are fit perfectly but the views with some fixed subviews fail. Could anyone please give me some suggestions on how to fix this? Any help is appreciated. Thank you very much!
This is exactly what auto layout exists for. You can create a UI, using storyboards, that works perfectly for both screen sizes. You can toggle a setting in the storyboard to have it display the two different screen sizes, so you can easily see how your views will move and resize. There is also a preview mode for the storyboard that lets you see how it will look. It also lets you see how it will look on both iOS 6 and iOS 7, so that you can make sure that your UI looks good on both assuming you still support iOS 6.
If you had done this in code, it would probably have been a whole lot more complicated, especially since you have to run it each time to see what changes when you adjust your code. Graphical layout tools such as Interface Builder (what allows you to view and edit storyboards and XIB files) make supporting multiple screen sizes very easy. Plus, generally it's not too hard to make a screen designed for a 4" screen work with a 3.5" screen, in some cases you just have to make things fit a little closer together, or perhaps have the content in a scroll view.

Resources