I have a UIImageView inside a UIScrollView with zooming enabled in the scrollView. What I want is if a user has zoomed into a particular region of an image , and then comes back , the scroll view sets the image wherever it was left. I have tried using content offset but it's not working for all zoom levels. In the case of zoom level 1 the imageView kind of sticks to the left of the scrollView . This is the code that I have used to save the contentOffset and zoomScale .

```
    -(void)saveContentOffset
{
    NSInteger zoomValue=[Scroll zoomScale];
    CGPoint offeset=[Scroll contentOffset];
    NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
    [dict setObject:[NSNumber numberWithInteger:offeset.x] forKey:@"X"];
    [dict setObject:[NSNumber numberWithInteger:offeset.y] forKey:@"Y"];
    [dict setObject:[NSNumber numberWithInteger:zoomValue] forKey:@"Zoom"];
    [[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"Dict"];
}

```

and this code is used to set the contentOffset when the user comes back on the screen:

```
-(void)setContentOffsetForScroll
{
    NSDictionary *dict=[[NSUserDefaults standardUserDefaults] objectForKey:@"Dict"];
    if ([dict allKeys]>0)
    {
        NSInteger xPoint=[[dict valueForKey:@"X"] integerValue];
        NSInteger yPoint=[[dict valueForKey:@"Y"] integerValue];
        NSInteger zoomScale=[[dict valueForKey:@"Zoom"] integerValue];
        CGPoint offsetPoint=CGPointMake(xPoint, yPoint);
        [Scroll setZoomScale:zoomScale];
        [Scroll setContentOffset:offsetPoint];
    }
}

```

Please check the attached image for the issue in the case of zoomLevel 1 , the view at background with greenColor is ScrollView . In this case the content sets to left .

Please suggest what exactly I am missing.

Thanks!![enter image description here](https://i.stack.imgur.com/PqIXN.png)