Design ViewController with Size class in Xcode 6, iOS 8 - iphone

I am exploring Xcode6 and I found that for storyboard or xib design now it has size class introduced. I tried to create design for iPad in portrait I didn't found any specific size class layout so I decided to go with wAny - hAny.
So I got a canvas with 600x600 size. When I put a UILabel with x = 100,y = 100, w = 60,h = 21 frame. So this frame is based on 600x600 canvas. When I run the app, on screen of 768x1024 that label has same frame. Nothing changed.
So how to design layout of iPad or different sized iPhones with a fixed canvas when it doesn't change it's subview's frame based on screen size. I googles a lot for sized class but didn't got anything helpful to design layout with size class.
Only thing I found is to either disable AutoLayout or to change ViewController's simulated size to freeform and make canvas size to 768x1024 but this won't help in designing multiple sized iPhone.

AutoLayout if your best (and only?) solution here.
The fact that you resized the view in the storyboard is irrelevant. It is merely there to help you set the proper constraints from within Interface Builder.
WWDC 2014: Building Adaptive Apps with UIKit (http://devstreaming.apple.com/videos/wwdc/2014/216xxcnxc6wnkf3/216/216_hd_building_adaptive_apps_with_uikit.mov?dl=1)
Documentation: https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html#//apple_ref/doc/uid/TP40014205-SW44
https://www.youtube.com/watch?v=IwSTXY0awng

As per your question you need to refer the link as it will clarify your issue with size class and auto layout constraint.
Any-Any size class with Auto Layout
Visit link below it has the great explanation and your most of issues related to auto layout using size class will be solved:
http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/
Hope this solves you problem.

Related

Xcode Not Displaying Correct Size In Storyboard?

I have an iPhone 6 to test my app i have my storyboard set to wCompact hRegular it says at the bottom this is for all iPhones in portrait and on the storyboard i can see all the content without a scrollview. However when i actually build and load the app to the device some of the content is off the screen when in the storyboard it shows otherwise. Does it not mean All iPhones in portrait or am i misunderstanding this feature of Xcode?
You are misunderstanding somewhat. Compact width regular height is a description of the style / shape / attributes of the screen for iPhones in portrait, not the actual size. They're all tall and skinny, but not all by the same amount or with the same aspect ratio.
Size classes allow you to logically group devices and orientations so you can specify the overall style of interaction that's appropriate, then allow auto layout to exactly configure the views to fit the available space.
Go to your storyboard and Select Your Viewcontroller in the right pane select show attribute inspector for the particular viewcontroller..and set Size to iphone 4.7 inch and orientation to portrait..and check your alignment is showing correctly ..check the image for references
http://i.stack.imgur.com/wrBSj.png

Xcode 7: UITextview doesn't aligned properly for 3 different sizes iPhone screen

I am trying to use adaptive layout in Xcode 7.1 for iPhone app. I am using 3 sizes iPhone device 5.5, 4.7 and 4.0 inches. When I added a background UIImageview, it fits nicely on all 3 iPhone screens. Please refer attached screenshot. I did pin option to Add 4 sides constraints with 0 values. Background fits to all 3 iPhone sizes screen fine.
Now, I am trying to add a UITextview in all 3 iPhone sizes screen. Now, this text view doesn't fit properly in all 3 iPhone sizes screen
Please find the screenshot reference below. How to make this textview properly placed on all 3 iPhone screens just below Employee ID label?
Follow this image and set your constraints like wise....
You have to set constraints to fit textfield properly. Firstly you have to set size class before setting constraints to handle orientation. like size class with respect to device size in this screen shot size class RH/CW set for portrait orientation. And set set constraints to fit UITextfield

How to well adapt height and position of views in iOS without AutoLayout?

I am building a view in Storyboard. I have three parts :
1) top : real-time camera view (adaptive height)
2) middle : small webview (fixed height)
3) bottom : some buttons (fixed height)
I would like to know how to properly make my interface in the storyboard for a compatibility with iPhone 4 or iPhone 5 screens.
My goal is to have the camera having a bigger part of the screen on iPhone 5 (or any bigger screen) and the webview and buttons to have the exact same height on any device.
I did it quite well with the AutoLayout feature. The only problem is that it is available since iOS6 and my app has to work from iOS5 and above.
My Storyboard has an 4' display and when I try to run it on a real device (iPhone 4S) all the bottom of the screen is cropped and I can't see my buttons. I really can't figure it out what is really the best and proper way to do it. For a such simple problem, I shouldn't build two different storyboards.
Maybe should I try to fix the height of the camera view programmatically, but this won't fix the problem of the bottom of the screen cropped on smaller screens (I should then modify the position programmatically).
You can see that I haven't a really nice solution to my problem. Could someone help me in how using well the tools in XCode for this case ?
Thanks
Try this:
Xcode 4.5: How do I fix my text views so they display properly in portrait and landscape mode on an iPad?
I think this could fix your problem and if you are using Storyboards it makes it less difficult.

UIImageView PNG pixelation on iOS simulator and on device

This may be a very simple issue, but I've been stuck with this for a week. I'm using an UIImageView to display a Dropbox branding PNG image. I see it alright in Interface Builder, but it's easy to notice a strong pixelation in the iOS Simulator and in the actual device (an iPad). Here I attach a screen capture of the IB together with the simulator:
I would really appreciate any hint.
Thanks in advance!
InterfaceBuilder is a completely different environment than iOS or even the simulator. Layout and such should translate, but the way everything looks should always be judged (and therefore designed for) the end product.
It looks like your image is being stretched slightly. There are any number of reasons for this. The first thing to check is the resizing mask on your UIImageView. It's generally bad for UIImageViews to autoresize - for this very reason.
By the way, autoresizing is UIKit's way of making sure that subviews still fit/look good when their parent view changes size. You can specify how much you want a subview to move around, also how much you want it to stretch. Read about it here.
What you will want to do is design your view -- answer the question: how big do I want this image to be in the final product? -- and then make the actual png that size (also produce an #2x variant that is double the size for retina displays). Then, when you design in IB, make your UIImageView that size as well, and make sure that the autoresizing settings are set to prohibit stretching.
This ought to fix your problem.
Check to make sure the size of the image matches the size of your UIImageView. If the image happens to be smaller than the target image view, it will stretch to fill it which could cause pixelation. Also, if you are running the new 5.1 Simulator for iPad, it will default to the new retina screen, which means you will need the #2x sized images to prevent pixelation there.

When I create an iphone window based app, how to tell interface builder create window for retina pixel size?

I hope to create an iphone window based app for retina screen?
But I found that the size of window in mainwindow.xib is fixed.
How to adjust it or there is any to tell interface builder create window for retina pixel size?
Welcome any comment
Thanks
interdev
There's no need to do anything in terms of the various components you layout in Interface Builder, as it's based around points, not pixels - and as all the iPhone screens sizes are the same in points no action is required.
In terms of any images you're loading, you will need to supply higher resolution (twice the pixel size) versions, but as long as these are named "[original name]#2x.[extension]" they'll simply work automatically.
For more information on the image naming, see the "Specifying High-Resolution Images in iOS" section of the Resource Programming Guide and if you want to delve a little deeper, there's a discussion on "Points Versus Pixels" within the Drawing and Printing Guide for iOS.
UPDATE - As of the iPhone 5, the iPhone screens are no longer all the same point size. :-)
The window will be automatically resized for you, you do need concern about the size of your image elements, since retina display uses a bigger size of resolution. You need name your images like this:
regular image name: myimage.png
retina image name: myimage#2x.png
When running in an iPhone4 your program will identify the token "#2x" and change the images for that kind of device.
Design your layout using the size of: 640x960 (double of the original: 320x480)
Good luck.