ScrollView inside scrollView in iOS

143 views Asked by At

I am creating photo browser.

I create VC that will be display photo and it can zoom/zoom out it. Also I create another VC that I use like a page control.

Now I can only page thought all photos and it works very good. Also If I load image in my VC for single photo I can zoom/zoom out it.

Now my purpose is to combine it. I want to have image pager VC that will be able go thought images and zoom/zoom out desire image. And then there is no space to zoom/zoom out it will be switch to other images.

I have tap gesture and pinch gesture in single image VC. How can I separate this events? Or how can I achieve it?

My code for is

ImagePagerViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self createPages];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    [self updatePages];
}

- (void)createPages
{
    for (NSUInteger i = 0; i < self.dataSource.count; i++)
    {
        NSURL *url = self.dataSource[i];
        AttachmentViewController *attachmentViewController =     [[AttachmentViewController alloc] initWithUserType:ImageViewer setActiveMode:None setInitialSeconds:NULL];
        attachmentViewController.imageURL = url;
        [self.scrollView insertSubview:attachmentViewController.view atIndex:self.views.count];
        [self.views addObject:attachmentViewController.view];
    }
}

- (void)updatePages
{
    CGFloat w = ScreenWidth;
    CGFloat h = ScreenHeight;
    for (NSUInteger i = 0; i < self.views.count; i++)
    {
        UIView *view = self.views[i];
        view.frame = CGRectMake(i * w, 0, w, h);
    }

    self.scrollView.contentSize = CGSizeMake(self.dataSource.count * w, h);
}
0

There are 0 answers