Zooming an UIView without losing detail - ios

Let's say I have a complex UIView, which is initially on the screen with quite small frame, let's say 80x80.
One of its subviews is an UIImageView displaying an image whose actual resolution is 1024x1024.
When the user tap the UIView i want the view to zoom in almost full screen so that the user can better see the image.
I know already how to scale a UIView to zoom in, my question is the following.
What's the best way to zoom in this view without pixellating the image?
I thought of these options:
I can actually set the frame of the UIView to the full screen size, and normally scale it down, so I'm sure that when it's zoomed in, it will be perfectly detailed. This solution anyway have a strong performance issue, cause moving around many of these scaled down views, will be quite an hit on the CPU/GPU.
I can do it just as I described, so small frame and scale > 1 to zoom in, but in this case will the image be displayed without pixellating?
I can actually set the frame to redisplay the view at the big/small size. In this case the detail will be good, but I have a performance hit here too, because my UIView have around 15 subviews that need complex calculation to relayout, so it's not so "fast" to set the frame.
Which is the best solution? Or do anybody have any other better solution?

Why dont you just have thumbnail representations that are 80x80, and when the user taps on any thumbnail, you transition from your current view containing all the thumbnails to a new view with the +transitionFromView:toView:duration:options:completion: method and simply display a UIImageView with the full resolution image loaded into that new view :)

Related

Resizing Complex UIView with AutoLayout (Swift)

So I'm pretty new to AutoLayout, but more often than not I'm able to hack my views into shape or model off samples on the web.
However, I've created this rather complex view that just doesn't resize no matter what constraints I try.
Here are a few screenshots of what's going on.
The first shot is my Interface Builder layout. It's got a 4-corners kind of thing going on, with a UIImageView in each corner. In the center is a blurred VisualEffectView; it lays on top of the images. The layout was constructed with the parent view at 200x200
The second shot is a successful rendering at 200x200. As you can see, the 4 images load fine (yeah, I know they're a bit stretched, I just haven't handled their scaling code yet). Programmatically, I set the cornerRadius properties of both the parent view and the blurred view to 1/2 their width, so as to make them circular. Also programmatically, I added a label as a subview to the blurred view.
Then it all goes downhill. The third shot is my attempting to render the view at 250x250. The parent view renders well and maintains a circular shape, but just about everything else is wrong.
The most frustrating part is the UIImageViews, which all go haywire and extend their bounds even though I've set them to be equal widths.
The blurred view at least stays centered, but something isn't called which prevents its bounds.width property to be updated, which is what the cornerRadius is based off of.
The label doesn't stay center in the blurred view, despite setting its autoesizingMask to flexible all around.
Here is a snippet of my initialization code, which might be useful.
Any help that you all could provide would be greatly appreciated (even if it just fixes one of the several issues).
P.S. I apologize for the cats pics.
Edit: I achieved the desired result by writing the code manually and ditching Interface Builder and AutoLayout entirely.

Outbounds Image Pieces in PageCurl Transition on UIPageViewController

I have an application in which I have implemented the system transitions between views UIPageViewController offers. The problem I have is that in each view images placed indicating the Frame where they have to be affixed. If this frame outside the screen, when I make the transition to pass page, the pieces of the images protruding frames page are shown. I know the best way for do this is edit the image erasing this piece, but the problem is that this images with I have the problem, are dynamically set in place for each size of screen
The best way to this is setting view.clipsToBounds = true.

Adjust UIView inside UIScrollView MultiOrientation

In my app i receive a image dynamically.
After process the image i need to add some views on top of that image (after the user can drag this views).
To accomplish that, i put the image on UIImageView and add the views on that UIImageView.
According on its dimension i need to adjust the UImageview to fit the screen, but maintain the original scale.. The user can also make zoom.
The main problem appears when the user rotate the device. I need to adjust the UIImageView and it´s subviews correctly to maintain their relationship with the image.
For example in portrait:
And Lanscape:
My doubts:
Correctly adjust the UIImageview´s size, maintainig it´s original scale.
Adjust the subviews to maintain their relation position to the UIImageView.
Thanks in advance

Problems rotating in the middle of a pan with UIViewPageController-based slide show

I have an image slide-show viewer that uses a UIPageViewController to present the images.
The image-view viewer ViewController is pretty simple -- a top-level view containing a UIScrollView containing a UIImageView. On initial image presentation or when the device is rotated the image is aspect-fitted to the view dimensions and centered. It works fine except for a problem which happens on both iOS 7 and iOS 6.
If I am in the middle of panning to change images and two images are on the screen and I then rotate the device it sometimes (maybe always?) messes up the display of one or more images. The previously-centered image appears in the wrong place on the screen and this persists when rotated and zoomed.
The only thing I can find wrong when this happens is that the center property of the UIImageView is not, in fact, the center of the frame. If I change the center property of the UIImageView in viewDidAppear to be the center of the possibly-scaled UIImageView then the images seem to display correctly in all cases.
Does this sound like the effect of some familiar mistake that I'm making?
Edit to respond to the question:
I don't do anything in the willRotate or didRotate methods.
In viewDidLayoutSubviews I aspect-fit the image into the current UIScrollView bounds (which is the full top-level view which is the full screen) and center it. This takes care of both the initial presentation and rotations. I don't see any problems in "normal" rotation situations. The problem occurs only when I rotate with two of the pageViewController's children views both partly onscreen at once. I can "fix" the problem in all cases but surely I'm doing something wrong.
Edit 2
I've discovered another anomaly that occurs less frequently when rotating the device while panning with 2 images onscreen. Best explained by an example:
The page view controller is being used to display one image in a sequence of images from left to right of A B C. Image B is onscreen. During a pan to the left you see part of both images A and B. If the pan to image A is nearly complete, i.e. B is nearly offscreen, and you rotate the device then image B normally ends up onscreen (it never rotates still showing the partial pan), but sometimes image C ends up being displayed -- as though you had panned in the other direction. Anybody else see this kind of behavior?
What are you doing in your UIViewController to prepare for the rotation?
– willRotateToInterfaceOrientation:duration:
And then how do you recover once the rotation has finished?
- didRotateFromInterfaceOrientation
These calls are provided specifically so you have a chance to get ready for a rotation, and then to put everything back to normal once it completes.

UIImage or UIImageView with paging and zoom on click

I have a UIView in which I get certain information about a user, wthin a bunch of textfields and a bunch of photos of him, if available.
No Im a bit limited here, so I must have a UIImage or UIImageView on my View (only the first half of my view, to display this images.
Up to now I have a array of this images in the background and as soon as the user swipe over the UIImageView, the image shows the next.
But it's ugly, becuase there is no real paging (you know, see the second image in pieces while you swipe, at the moment its only a UIMageView.Image = xxx and its ugly) and no zooming (zoom on click).
Any idea to solve this?
Use an UIScrollView and place all of the images in it (as UIImageViews).

Resources