Image is getting blury when Zooming In - iphone

I am trying to zoom to a image in my view. For that I used UIScrollView and in that scrollView I placed a ImageView. I had set min and max zoom scale of scrollview.
I used this code too..
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imgView;
}
The problem is My image gets blury while zoomig. Any one have idea how to redraw image with the zoom size.

hi set maximumZoomScale=1.0f. it wont blurr :)

Related

move an image with touching like a scrollview

Well I have an image and I I want that when I touch it and then I move my finger it follows it.but I want that it follows it only vertically like a vertical scrollview(but I don't wanna use a scrollview).How can I do this please. sorry for my english I'm french :/
Why wouldn't you subclass UIScrollView for your view that displays the image? If you do it's pretty simple: define its size so that the horizontal length doesn't exceed the screen length. You'd have to also remember to change this if you allow rotation of the device/view to landscape. Suppose the width of your UIScrollView is 320, you would do this:
CGSize scrollableSize = CGSizeMake(320, myScrollableHeight);
[myScrollView setContentSize:scrollableSize];
Where myScrollableHeight is the full height of the image.
I've never used it but if that doesn't work there is apparently a method you can provide for your UIScrollView class that is called whenever the user attempts to scroll and you can just not adjust the X-coordinate there:
float oldX; // make this ivar in your .h file
- (void)scrollViewDidScroll:(UIScrollView *)aScrollView
{
[aScrollView setContentOffset: CGPointMake(aScrollView.contentOffset.y, oldX)];
}
Take a look at Apple's MoveMe sample. This should give you an idea. If you only want it to move vertically, only change the y value while dragging.
Just adding a panning gesture to the image parent view and moving the image.center (only the y in your case) should be enough. Look at apple documentation for more details

iPhone ScrollView zoom problems

I'm new to iPhone dev and Obj-C and I have several problems with ScrollView/ImageView while getting close to deadline. I used IB to create interface so I access most parameters via builder.
1) I was using touch events (begin/moved/ended) on imageView to switch images. When I put ImageView to ScrollView the old gestures stopped working and I can only zoom. If scrollView of both have focus I can't use my gestures even when zoomed out. How can I use both?
2) How do I zoom only image part of view? Unfortunately I also see background area around :/ What's worse - after rotating the view keeps it's old dimensions and I have even more black areas around image. For some reason image is in top-left corner.
Code snippets I found doesn't really help me much in this case. I have various images of different sizes in imageView to switch and zoom in/out.
EDIT: Ok, a little different. How do I override scrollview touch mode so that when image is zoomed out (to screen size) "normal" gestures would work. Currenly I have either scroll view scrolling or gestures, can't use both. Anyone?
Solved by dynamically changing imageview to imagesize and switching like:
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
if (scrollView.zoomScale==1.0) {
scrollView.userInteractionEnabled = NO;
imageView.userInteractionEnabled = YES;
}
Not the best solution but works good enough.

ScrollView Zooming problem

In TapToZoom sample(apple code), If i pinch(inwards) the image becomes smaller than the window size(If i remove fingers it will fit correctly to window). How to fix the image to the window if the content size of scroll view is less than window size. I spent a day to fix this problem but of no use...
I am attaching the snap..
The black color is my window of size(320*480) if i pinch the image has gone smaller than the window size(highlighted image) If i stop pinching at this time It will fit correctly to window. But i don't want my imageView to become smaller than window while pinching how to accomplish this?
Thanks,
You may want to look at the minimumZoomScale and maximumZoomScale properties of UIScrollView (Reference here)
I adding these condintions in my delegate to fix the problem...
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(scrollView.zoomScale < minimumScale)
{
[scrollView setZoomScale:minimumScale];
}
else if(scrollView.zoomScale > 1)
{
[scrollView setZoomScale:1];
}
}

How to get active subview (UIImageView) from UIScrollView

I have several UIImage subviews in one UIScrollView. I'm trying to emulate iPhones's Photos app. To enable pinch zooming, I have implemented UIScrollViewDelegate and the one thing I'm unable to figure out is this delegate function:
(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
How do I find out which UIImage subview is currently active?
Something like:
(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return activeUIImageViewSubView;
}
You probably want to keep track yourself of the current UIImage subview.
Or if you have only one visible at a time, look for the one with the coordinate values that make it visible.
If you want to zoom them all at the same time, you may want to group all your UIImage in an intermediate UIView that could be scrolled and panned.

UIImageView Zoom in and out

I want to change the images depending upon the zoom in or zoom out.
Means if i am zoom upto certain limit then it should show other image.
I added one UIImageView in UIScrollView and zoom in and out functionality is working but i am not getting how to change image during zoom in and zoom out.
And while changing image it should have fade effect in between.
Can any one help me for this?
UIScrollViewDelegate has a method - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale.
In this method you can check the scale and update the UIImageView with the appropriate UIImage.
For animating an image change, you can do:
[UIView beginAnimations:#"imageChange" context:NULL];
yourImageView.image = yourNewImage;
[UIView commitAnimations];
The change will have the fade effect you want.
About the zoom-in and zoom-out functionality I'm not sure, but you should check if the view is zooming (zooming property for your UIScrollView should be true) and then use the zoomScale property. I suppose you could do this with a timer, continuously checking if the view is zooming.