GDSheetController
GDSheetController copied to clipboard
Vertical scrolling through view controllers
Is it possible to vertical scroll through all the view controllers?
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.
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.