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
Related
I have a UIImageView set on top of a scrollView. The image is a map, and I need to annotate buttons across the map to corresponding locations (very specific to the region). The buttons are visible, and they pan and scale accordingly when scrolled/zoomed, this works great. The issue is when the buttons are rendered on different screen sizes, the buttons are placed in different spots since auto-layout puts them the same distance from the edge of the screen, but the image has a different bounds property and is bigger/smaller depending on the device.
I've considered creating an MKMapView with a custom overlay of this image, but I was hoping to keep it super light-weight and avoid MapKit all together.
Any suggestions? Clarifications are fully encouraged :)
You should add buttons as subviews on imageview so that buttons transform in the same way as imageview does.
In my iOS app I want my users to be able to zoom in on the screen. My main uiview contains several subviews which contain images. I want my uipinchgesturerecognizer to either change the scale, or ideally use some "zoom" rather than scaling each subview.
Please and thank you.
This can be accomplished with UIScrollView. First create a scroll view as the base of your view hierarchy, putting your previous container view as a subview of the scroll view. Set the delegate of the scroll view to self and implement the delegate method viewForZoomingInScrollView, in which you should return the view that will be zoomed in (your original container view). This will allow the user to pinch and zoom your original UIView.
It's hard to provide advice on this without having a clearer view of what exactly you want to achieve.
Can you include a link to a sketch? For example, do you want the individual subviews to remain the same size but the layout to change ? Do you want the individual subviews to resize but their contents to be upscaled?
If you simple want to treat the subview as (basically) a single image which just happens to have other images in it, then maybe it would be better to render it as one and then scale that?
Well pretty straight forward.
FBProfilePictureView uses (by my knowing) all the UIImageView methods. Knowing this i tried to use AscpectToFit (first in the storyboard second in the code when the first one didn't work.
the i tried this:
self.fb_background.contentMode = UIViewContentMode.ScaleToFill
This works only in height. I also tried resizing the frame this resulted in my images halfway down my page(instead of the top left
what am i doing wrong?
The problem is that my pictures width is not correct! its
The problem is that FBProfilePictureView contains a UIImageView and does not expose it for you to modify it's properties.
It downloads a square image if pictureCropping == FBProfilePictureCroppingSquare otherwise it downloads a small, medium or large image depending on the width of the frame. But there is no way to control how this image is scaled to fill the FBProfilePictureView.
I created a replacement view which exposes the UIImageView through a read-only imageView property and therefore allows you to control its contentMode.
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 :)
So I am new to autolayout in iOS and so I have run into a problem.
My program has 2 imageviews which can be dragged around,pinched, zoomed in and rotated. The user should be able to drag the image views anywhere on the screen. So basically I dont want constraints holding my images in place. I need autolayout to be off for the 2 image views alone (and I know thats not possible).
So whats happening now is when I run the program, the image views can be dragged to anywhere in the screen but when I rotate it or pinch to zoom it, the image moves from its current position and gets placed at the center of the screen, and there it will be zoomed or rotated.( Center contraints are there and they are on lowest priority). I can't seem to delete the constraints either.
Is there anyway I can avoid the constraints just for the image views???If not, what can be the solution to my problem??
override -(void) layoutSubviews in your UIViewController
That should do the trick :)
Take a look at this question. It explains how to disable auto layout for a specific uiview at runtime.
Can I disable autolayout for a specific subview at runtime?