I read as much as I can of auto-layout tutorials but I cannot figured out how I can have my UIView (UIWebView for that specific example) resize to the screen layout of my phone.
My background is an UIImageView, proportionally bigger on iPhone5, and iPhone6 and iPhone6 plus .
I want to have my UIWebview to get the margin keeping the aspect ratio.
I tried several options (I also enabled size classes option - I did not see any difference on the preview...)
Anyone as a clue on that ?
It looks like you're not getting any answers here, and I'm not sure I can help, either; but, I'd like to try by offering what I've done with respect to maintaining the aspect ratio of a given view containing a video, no matter whether the iPhone orientation is portrait or landscape.
In my storyboard, I've accounted for occasions in which the aspect ratio is reversed, in that all videos are either 16:9 or 9:16, but which one depends on how the camera was held during recording:
So, here is a screen shot of an iPhone displaying a 16:9 (wide) video in portrait:
Here is the same video (wide) in landscape (ignore the overlapping labels; the Core Data section is meant to be hidden or overlapped by the AVPlayer view, so that users can view the video fullscreen by simply rotating the iPhone):
Here are the opposites, first:
And, second:
These run the gamut of possibilities for maintaining aspect ratio, regardless of a portrait or landscape orientation, and regardless of a horizontal or vertical aspect ratio. Therefore, you should be able to derive a solution from it. Hope this helps!
Related
I want have an image on my launch screen which occupies the same amount of the screen on different devices.
At the moment I have a logo which is about the right size on iPhone 4s, but on iPhone 6 Plus it's too small. Obviously these devices are in the same autolayout class.
I know I could use proportional sizing, but this will stretch the images and make them look fuzzy.
Also with it being a launch screen I can't use code for drawing or custom controls.
I guess I need some way to determine different devices in my constraints.
Add LaunchScreen asset group to your Assets. Then it will be possible to assign custom image for each screen resolution.
I have a fancybox with slider ,the width of the fancybox is set to the width of the screen width the slider is loading fine in all devices except in iphone landscape view,if i view the fancybox slider in landscape view of iphone it is taking the width of the portrait view
In reality, what you want to do is give your slider a proportional width to its superview that way when the phone is in either landscape or portrait it follows that proportion. Worst case scenario you would have to change your size class and add constraints to your slider in that size class. Although that is just a hack, and I don't suggest doing it this way.
I’m assuming you created your view in interface builder and you did not configure it to resize when the device rotates. There are two ways to do this:
Old: Springs and struts
New: Autolayout
I would suggest you use Autolayout. Instead of providing a specific link just google "autolayout tutorial" or "introduction to autolayout" and you can pick the link that works best for you to explain that. There are also some tutorials on YouTube. For a bit more of an advanced but comprehensive tutorial try one of the online Stanford videos:
Stanford University Developing iOS 7 Apps: Lecture 9 - Animation and Autolayout
https://www.youtube.com/watch?v=r1sc7NI6-wo
You just need to watch the part about Autolayout and skip the piece about animation.
I had Used UICollectionView to show three images in each cell in portrait and landscape mode using AutoLayout. Fetch images from server to load in UICollectionView data. In iphone 4s and 5 working little better but iphone 6 and 6 plus Image stretching issue in portrait and landscape mode. I had tried AspectFit but i need to fill image in full space. I had spent more time with this so How to solve this issue? please let me your suggestions.
Thanks in Advance
FYI, Screenshot
You need to use AspectFill
AspectFit Keeps the aspect ration, but showing all the image, therefore it won't fill your imageView, and AspectFill keeps the aspect ratio, and filling your imageView, therefore it wont show all the image, think about it like sort of cropping the image to fit in your imageView.
I'm coding a remote control with a background (designed in Photoshop) already for the iPhone 6+ with the proper resolution, which I use with an UIImageView at full size.
I disabled Autolayout/Size Classes and set the size to Inferred. Further I uploaded all relevant LaunchImages for proper scaling.
The UIImageView scales properly for all screen sizes, but the buttons I put over the background are moving.
For example:
All buttons (over 1-9, Power Off, Menu ecc.) should always stay at the same position (in releation to the selected device and screen resolution).
I can't get it, that all buttons stay over the designed photoshop elements.
Please give me a good advice, to solve this issue.
I would recommend using size classes and Autolayout. This type of thing is exactly what they are made for.
This youtube video is a great introduction to size classes and some Autolayout:
https://www.youtube.com/watch?v=IwSTXY0awng&feature=youtu.be
I've been working on a specific app for a while now and everything was good. But upon all this news of the iPhone 6 and the new Xcode, everything has just become confusing. Using Auto layout and designing for the iPhone have just become the most complicated thing to do. Every time I add constraints my images just triple in size. When all I want is to resize them to fit rationally across all the iPhone platforms(In portrait mode). For example I would like for certain images to grow as I work From the iPhone 5 to the 6+. Does any one know how to do this?
What do you mean triple in size?
Easiest way to have an image view scale is do the following:
Add it as a subview to the view of your view controller
Pin it at the top, left and right, leaving height unconstrained
Add an aspect ratio constraint, so that it can automatically calculate its height based on the width it gets