3
votes

i am newbie in iOS Development. I know this Question asked more times but i not get Answer for it. Here i add my image in to one UIImageview and Then add this UIImageView into UIScrollView i write a code for this like as

 for(index=0; index < [self.imagesa count]; index++)
{
    NSDictionary *dict=[self.imagesa objectAtIndex:index];
    NSString *image=[dict valueForKey:@"link"];
    bigImage=[[UIImageView alloc]init];
    bigImage.userInteractionEnabled=TRUE;
    bigImage.tag=123;
    bigImage.tag=index;
    bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    bigImage.frame=CGRectMake(index * self.zoomScroll.frame.size.width, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    [self.zoomScroll addSubview:bigImage];
    [bigImage setMultipleTouchEnabled:YES];
    [bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
    [bigImage setUserInteractionEnabled:TRUE];
    [self.objectarray insertObject:bigImage atIndex:index];
    CGSize scrollViewSize=CGSizeMake(self.zoomScroll.frame.size.width*      [self.objectarray count], self.zoomScroll.frame.size.height);
    [self.zoomScroll setContentSize:scrollViewSize];
    [self.zoomScroll addSubview:[self.objectarray objectAtIndex:index]];
    self.zoomScroll.scrollEnabled=YES;
    self.zoomScroll.clipsToBounds=YES;

and i write a ViewforzoomInScrollview like as

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return bigImage;
}

Here my Scrollview Contain all images but when i Zoom then it Zoom only First image and After Zoomed Scrollview Size is Set as Fixed and it is not Scroll. Here i set all Property delegate of Scrollview like as MaximumZoomScale,MinimumZoomScale but it is Not Zoom Curreent image in Scrollview it Zoom Always First Image of Imageview please give me Solution for that.

1
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return bigImage; } you are returning here the bigImage . it is global or may be the property that is why it is showing first or the last image youSmile
did you take this as property or global bigImage?Smile
are you using scrollview paging concept or normal scrollview?Smile
Yes here Scrollview Paging Enable.and big image is globally Declare.user4202773
once try this pastie.org/9733879 just use int before pageint.Smile

1 Answers

0
votes

This tutorial on raywenderlich covers exactly what you want to do.

My guess is that you have to set a minimum / maximum zoom level on the UIScrollView