Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical scrolling through view controllers #3

Open
beloso opened this issue Jun 30, 2015 · 2 comments
Open

Vertical scrolling through view controllers #3

beloso opened this issue Jun 30, 2015 · 2 comments

Comments

@beloso
Copy link

beloso commented Jun 30, 2015

Is it possible to vertical scroll through all the view controllers?

@iGranDav
Copy link
Owner

Yes it could be possible but you'll have to deal with gestures already present on controller sheets representations.

Put the expand sheet gesture only on the header and then put the GDSheetController view instance inside a UIScrollView.

Or feel free to fork the project, add it directly to the GDSheetController component and proprose a PullRequest I'll be happy to merge it.

@beloso
Copy link
Author

beloso commented Jul 1, 2015

Perhaps I am doing something wrong, but here is how I'm adding the GDSheetController to a scrollview:

in GDSheetController.m

- (id)initWithControllers:(NSArray *)arrayOfControllers
                  options:(NSDictionary *)options
{
    self = [super init];
    if(self)
    {
        //Set view controller frame correctly
        self.view.frame = self.view.bounds;
        // Adding a scrollview
        self.contentView = [[UIScrollView alloc] initWithFrame:self.view.frame];
        [self.view addSubview:self.contentView];
        self.contentView.contentSize = CGSizeMake(self.view.frame.size.width, 5000); //this must be the appropriate size!

        if(options)
        {
            self.controllerOptions = [options mutableCopy];
        }

        [self commonInitGDSheetController];
        [self addControllerSheets:arrayOfControllers];
    }
    return self;
}

and later on...

- (void)addControllerSheets:(NSArray*)arrayOfControllers
{
    NSUInteger idx = 0;

    self.numberOfSheets = [arrayOfControllers count];

    for(UIViewController *vc in arrayOfControllers)
    {
        UIViewController *embedded = vc;
        UIViewController *preview  = nil;

        if([vc isKindOfClass:[GDEmbeddedControllers class]])
        {
            embedded = [(GDEmbeddedControllers*)vc embeddedController];
            preview  = [(GDEmbeddedControllers*)vc previewController];
        }

        embedded.sheetController = self;

        GDSheetView *view = nil;

        if(preview)
        {
            view = [[GDSheetView alloc] initWithEmbeddedController:embedded
                                                 previewController:preview
                                                   sheetController:self];
        }
        else
        {
            view = [[GDSheetView alloc] initWithEmbeddedController:embedded
                                                   sheetController:self];
        }

        view.delegate = self;

        [self.sheetControllers addObject:view];

        view.defaultTopInSuperview  = [self topOriginOfSheetAtIndex:idx];
        view.top                    = view.defaultTopInSuperview;
        view.currentScalingFactor   = [self scaleFactorOfSheetAtIndex:idx];

        if(preview) [self addChildViewController:preview];
        [self addChildViewController:embedded];
        [self.contentView addSubview:view];
        [self.contentView sizeToFit];
        if(preview) [preview didMoveToParentViewController:self];
        [embedded didMoveToParentViewController:self];

        idx++;
    }
}

I am trying to accomplish something like the android recent applications menu in Lollipop

I am not sure what I am doing wrong in the scroll view. Can you help me a bit with the scroll view?

The gestures I have already fixed to my needs.

811732803_767873331620178866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants