I am in the middle of creating a custom background page with simple UIImage inside a UIImageView.
What I am trying to do is to be able to fit my image the way photos app handles images.
for default portrait camera pics : seems like an aspectToFill?
for default landscape camera pics : aspectToFit for whole page (320,480)
other custom saved pics: ???
Here, I want to avoid as much empty space possible without hurting how images are perceived to the users.
Thanks for your suggestions
you must use aspectFit if you want to see the whole image, at the correct aspect ratio.
you are assuming that its aspectFill for portrait. But that'd be true only for a portrait image being viewed in Portrait (or a landscape image viewed in landscape).
Related
I have this annoying problem where Safari Mobile rotates the pictures I take with the phone camera. The weird thing is that it only happens while in portrait mode.
Here's a code sample: http://jsfiddle.net/Kazpp/
As you can see I'm adding the image as background of the preview div and setting the background-size property as cover so I can keep the image aspect ratio and fill the whole div area with the image.
I also tried adding an image element as children of my div, but that didn't worked either.
Does anyone have any clue on what's going on here?
Ps.: I'm having this issue on iOS 6.0. Didn't tried another iOS version.
You're running into an Exif orientation issue JS Client-Side Exif Orientation: Rotate and Mirror JPEG Images
As answered in that post you can use this library to check image orientation and rotate accordingly https://github.com/blueimp/JavaScript-Load-Image
I did nothing but setting up my captured image into UIImageview
No extra custom settings
No transformation
No resizing, nothing
Then why my image view returns rotated image.
I found the solution using
UIImage* rotatedImage = [UIImage imageWithCGImage:image.CGImage
scale:1.0
orientation:UIImageOrientationRight];
Now, I get original image. But though I just want to know the reason for automatic rotated image.
Note: this happens only when picture is captured from cam, if we choose picture from gallery then it doesn't get rotated & looks proper.
Any help is appreciated !!
This could depend on the extra "shooting information" eventually added by your camera. E.g. if you take a picture with an iPhone in portrait mode ("vertical") then the image will still have the original size (2048x1536) but with the "orientation" shooting information set to "rotate 90deg". Probably UIImageView doesn't read the shooting information and show the image as "raw", that is rotated (this is the image that has been physically taken by the sensor).
Consider this: if you rotate the iPhone the physical sensor will be rotated too and the iPhone "artificially" shows the image for you to display is correctly.
You can check this by taking two photos with your iPhone, in both orientations, and then connecting the iPhone to your Mac and start the "Image Capture" app. You will see that the two photos have the same size but one will be rotated vertically. You can check the shooting information instead using Preview.
As far as the "picture taken from gallery", my guess is that the gallery does the orientation for you and returns to you not the raw image but the image after the orientation has been applied (exactly as you did in your code).
I am using a UIWebView in my app and when I rotate my iPhone the webview rotates along with it, works just fine. However, you see the corners of the background view behind my webview as it rotates and it can look a little flickery when rotating.
So I went and tried Safari on my iPhone, using the same website and it different. In Safari if I rotate, its far smoother, I can also see it zooms slightly.
For example, I am on Apple's homepage in portrait mode, fully zoomed out to see the whole page. I rotate to landscape and the contents zooms, as far as I can observe this is why it looks smoother.
So, my question, how can I achieve this in my app?
I have played with the 'Scales Page To Fit' option but had no success.
Currently:
Rotating scales the webpage to fit the view. (Whole page is zoomed out to be seen).
Required:
When rotating, rather than rescaling the page, just let it zoom as required.
Don't know if this will help you, but you might find it useful to change the background color (or even background image) of the view behind your webview, which might mitigate your issue with seeing the corners.
If you haven't found a solution yet... As an alternative you could try refreshing the webview, if you notice that the device has rotated, refresh webview and webkit should renderize it again, also play with the HTML meta viewport tag (initial zoom, scale, etc.) and CSS media queries to support different scales. As for the HTML document, try using em, and pt units in CSS rules.
//reload webview
[self.webView reload];
link Orientation Notifications
hope this help in something
Beginner here. My app shows an UIImage (in a scroll view).
If you are on retina device, then it should not scroll and I set the scroll view frame to be
the exact size (640x960).
If you are not on a retina device then it should scroll, so I set the scroll view frame to the pixels (480x320).
I have this working by setting the frame sizes, as mentioned, in viewDidLoad()
So...my question is that I have to keep both images on disk. I have pix.png and pix#2x.png and they are exactly the same thing.
Any help on how to handle this? Maybe it is obvious, but not to me ;-)
thx!
In my opinion,If you load the image with the two file name, I think you should keep them on disk.If not, you can delete one of them. Nomatter what pixels size you set, the original pixels datas are always which image file you load from disk.
No, you shouldn't need two copies of the same image. The #2x scheme is just lets you automatically load a high resolution image when one is available. It sounds like you're already managing your scroll view's content size and things are working, so you can just get rid of the pix#2x.png file.
I'm not sure it's a great UI decision to change the app's behavior based on its screen resolution, though. Since you're already using a scroll view, it can be easy for the user to zoom in and out. Non-retina devices will display at native resolution when zoomed in; retina devices will display at native resolution when zoomed out.
I have a universal iOS app with a custom view that has three buttons, each with an image background that extends to the sides of the screen for each orientation (portrait and landscape). The heights of each of the three buttons are the same and all three buttons take up the whole screen. So it looks simliar to this layout (image on the far right).
Since the widths and heights of each button are the same, I need to calculate how big (in pixels) I need to make each button image in order to support both orientations of the iPad and iPhone. On top of that, I also need to create higher res images to support the new Retina display. My questions are...
How do I calculate the resolution these images need to be for...
iPad in both portrait and landscape mode
iPhone in both portrait and landscape mode
iPhone with Retina display
Instead of having two sets of images to support both Retina and non-Retina displays, can I just use one hi-res set that will be scaled down to the non-retina displays? if so, is this a good idea?
If I add a navigation controller and/or a toolbar, what are the heights of these two view objects so I can adjust the heights of my images?
Thanks so much in advance for all your help! I'm going to continue searching for these answers right now.
Good info on porting apps / graphics to retina display is here
Essentially Apple created a new unit for graphics called "points" and if you add additional images to the bundle and use new API you can automagically load one or the other image.