You can use Pinch gesture recognizer for zoom in/out. Check following link.
Up vote 0 down vote favorite share g+ share fb share tw.
I am using this code for zoom in and out image in a scroll view. But I don't know what is wrong because zoom in is not working? Const CGFloat kScrollObjHeight = 460.0; const CGFloat kScrollObjWidth = 320.0; const NSUInteger kNumImages = 32; - (void)layoutScrollImages { UIImageView *view = nil; NSArray *subviews = scrollView1 subviews; // reposition all image subviews in a horizontal serial fashion CGFloat curXLoc = 0; for (view in subviews) { if (view isKindOfClass:UIImageView class && view.
Tag > 0) { CGRect frame = view. Frame; frame. Origin = CGPointMake(curXLoc, 0); view.
Frame = frame; curXLoc += (kScrollObjWidth); } } // set the content size so it can be scrollable scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), scrollView1 bounds.size. Height); } - (void)viewDidLoad { self.view. BackgroundColor = UIColor viewFlipsideBackgroundColor; // 1.
Setup the scrollview for multiple images and add it to the view controller // // note: the following can be done in Interface Builder, but we show this in code for clarity scrollView1 setBackgroundColor:UIColor blackColor; scrollView1 setCanCancelContentTouches:NO; scrollView1. IndicatorStyle = UIScrollViewIndicatorStyleWhite; scrollView1. ClipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview scrollView1.
ScrollEnabled = YES; //imageView = UIImageView alloc initWithImage:UIImage imageNamed:@"image0. Jpg"; scrollView1 addSubview:imageView; scrollView1 setContentSize:CGSizeMake(imageView.frame.size. Width, imageView.frame.size.
Height); scrollView1. MinimumZoomScale = 1; scrollView1. MaximumZoomScale = 3; scrollView1. Delegate = self; scrollView1 setScrollEnabled:YES; // pagingEnabled property default is NO, if set the scroller will stop or snap at each photo // if you want free-flowing scroll, don't set this property.
ScrollView1. PagingEnabled = YES; // load all the images from our bundle and add them to the scroll view NSUInteger i; for (i = 1; I Jpg", i; UIImage *image = UIImage imageNamed:imageName; UIImageView *ImageView = UIImageView alloc initWithImage:image; // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList" CGRect rect = ImageView. Frame; rect.size.
Height = kScrollObjHeight; rect.size. Width = kScrollObjWidth; ImageView. Frame = rect; ImageView.
Tag = i; // tag our images for later use when we place them in serial fashion scrollView1 addSubview:ImageView; ImageView release; } self layoutScrollImages; // now place the photos in serial layout within the scrollview } -(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageView; } how add below code for zooming with above code? Define ZOOM_VIEW_TAG 100 define ZOOM_STEP 1.5 @interface RootViewController (UtilityMethods) - (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center; @end @implementation RootViewController @synthesize imageScrollView, imageView; (void)loadView { super loadView; // set the tag for the image view imageView setTag:ZOOM_VIEW_TAG; // add gesture recognizers to the image view UITapGestureRecognizer *singleTap = UITapGestureRecognizer alloc initWithTarget:self action:@selector(handleSingleTap:); UITapGestureRecognizer *doubleTap = UITapGestureRecognizer alloc initWithTarget:self action:@selector(handleDoubleTap:); UITapGestureRecognizer *twoFingerTap = UITapGestureRecognizer alloc initWithTarget:self action:@selector(handleTwoFingerTap:); doubleTap setNumberOfTapsRequired:2; twoFingerTap setNumberOfTouchesRequired:2; imageView addGestureRecognizer:singleTap; imageView addGestureRecognizer:doubleTap; imageView addGestureRecognizer:twoFingerTap; singleTap release; doubleTap release; twoFingerTap release; // calculate minimum scale to perfectly fit image width, and begin at that scale float minimumScale = imageScrollView frame.size. Width / imageView frame.size.
Width; imageScrollView setMinimumZoomScale:minimumScale; imageScrollView setZoomScale:minimumScale; } (void)viewDidUnload { self. ImageScrollView = nil; self. ImageView = nil; } (void)dealloc { imageScrollView release; imageView release; super dealloc; } pragma mark UIScrollViewDelegate methods (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageScrollView viewWithTag:ZOOM_VIEW_TAG; } /******************** NOTE ********************/ /* The following delegate method works around a known bug in zoomToRect:animated: / / In the next release after 3.0 this workaround will no longer be necessary / /***********************************************/ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { scrollView setZoomScale:scale+0.01 animated:NO; scrollView setZoomScale:scale animated:NO; } pragma mark TapDetectingImageViewDelegate methods (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer { // single tap does nothing for now } (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer { // double tap zooms in float newScale = imageScrollView zoomScale * ZOOM_STEP; CGRect zoomRect = self zoomRectForScale:newScale withCenter:gestureRecognizer locationInView:gestureRecognizer.
View; imageScrollView zoomToRect:zoomRect animated:YES; } (void)handleTwoFingerTap:(UIGestureRecognizer *)gestureRecognizer { // two-finger tap zooms out float newScale = imageScrollView zoomScale / ZOOM_STEP; CGRect zoomRect = self zoomRectForScale:newScale withCenter:gestureRecognizer locationInView:gestureRecognizer. View; imageScrollView zoomToRect:zoomRect animated:YES; } pragma mark Utility methods (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center { CGRect zoomRect; // the zoom rect is in the content view's coordinates. // At a zoom scale of 1.0, it would be the size of the imageScrollView's bounds.
// As the zoom scale decreases, so more content is visible, the size of the rect grows. ZoomRect.size. Height = imageScrollView frame.size.
Height / scale; zoomRect.size. Width = imageScrollView frame.size. Width / scale; // choose an origin so as to get the right center.
ZoomRect.origin. X = center. X - (zoomRect.size.
Width / 2.0); zoomRect.origin. Y = center. Y - (zoomRect.size.
Height / 2.0); return zoomRect; } in above code how zoom images in scroll view? Iphone objective-c cocoa-touch link|improve this question edited Jul 4 '11 at 12:15 asked Jul 2 '11 at 9:37ram50710 100% accept rate.
You can use Pinch gesture recognizer for zoom in/out. Check following link: How can I use pinch zoom(UIPinchGestureRecognizer) to change width of a UITextView?
So I can caht with you and ask my dout. – ram Jul 2 '11 at 11:21 I have a new query can you have any solution for that? – ram Jul 2 '11 at 11:51.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.