0
votes

i make an app that Contain UIScrollview with imageview my imageview Contain Array Image when i Press Zoom Button then i extended my UiScrollView Size and My Imageview Size then the only Last array image Size was Extended and it Was Overlaping on my First Image I want to make when Zoom Button Pressed then all my image is Zoomed and Not Overlaped each other i write a code for that like as

as initial Size

self.zoomScroll.frame=CGRectMake(10, 45, 300, 270);
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);

when ZoomButton was Pressed

-(IBAction)zoombuttonpressed:(id)sender
 {
 self.zoomScroll.frame=CGRectMake(10, 40, 300, 400);
bigImage.frame=CGRectMake(10, 40, 300, 400);
[self.zoomScroll addSubview:bigImage];
 }

Here zoomScroll is UIScrollview and bigImage is my UIImageView. then it was Zoom only Last image and it is overlapped in my first image of ImageView please Give me Solution for that.

Here when i modified Code like as

 -(IBAction)zoombuttonpressed:(id)sender
 {
 self.zoomScroll.frame=CGRectMake(10, 40, 300, 400);
for(int index=0; index < [self.imagesa count]; 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];

then overlapping issue was solved but my Array only last image was Zoomed means extended it's size and other are remanning as initial size please give me Solution for that.

i know this Question are asked more times but i confused about this because not get Solution.

2

2 Answers

0
votes

Here i got an answer my Self Like as

-(IBAction)showbuttonpressed:(id)sender
{
self.zoomScroll.frame=CGRectMake(10, 40, 300, 400);
for(int 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.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);
    [bigImage setMultipleTouchEnabled:YES];
    [bigImage setTag:1];
    [bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
    [bigImage setUserInteractionEnabled:TRUE];
    [self.objectarray insertObject:bigImage atIndex:index];
    [self.zoomScroll addSubview:bigImage];
    self.zoomScroll.clipsToBounds=YES;
    [self.zoomScroll addSubview:[self.objectarray objectAtIndex:index]];
 }
[self.zoomScroll addSubview:bigImage];
}
0
votes

You need to use "zoomScale" property of UIScrollView Class....

https://developer.apple.com/library/ios/documentation/uikit/reference/uiscrollview_class/index.html [UIScrollView Class Reference]