Skip to content

Commit

Permalink
Forward UIScrollViewDelegate from TTScrollSlidingPagesController
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-alex committed Jun 19, 2013
1 parent 166b078 commit faae579
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UIScrollSlidingPages/TTScrollSlidingPagesController.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

@property (nonatomic, strong) id<TTSlidingPagesDataSource> dataSource;

@property (nonatomic, strong) id<UIScrollViewDelegate> scrollViewDelegate;

/** @property titleScrollerHidden
* @brief Whether the title scroller bar is hidden or not.
* Whether the title scroller bar is hidden or not. Set this to YES if you only want the pages, and don't want the titles at the top of the page. For now even if this is set to YES you will still need to implement the `-(TTSlidingPageTitle *)titleForSlidingPagesViewController:(TTScrollSlidingPagesController *)source atIndex:(int)index` method in your datasource class, but you can just return nil for everything. Default is NO. **/
Expand Down
22 changes: 22 additions & 0 deletions UIScrollSlidingPages/TTScrollSlidingPagesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ -(void)viewDidLayoutSubviews{
#pragma mark UIScrollView delegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) {
[self.scrollViewDelegate scrollViewDidScroll:scrollView];
}

int currentPage = [self getCurrentDisplayedPage];

if (!self.zoomOutAnimationDisabled) {
Expand Down Expand Up @@ -504,6 +509,11 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
[self.scrollViewDelegate scrollViewDidEndDecelerating:scrollView];
}

int currentPage = [self getCurrentDisplayedPage];

//store the page you were on so if you have a rotate event, or you come back to this view you know what page to start at. (for example from a navigation controller), the viewDidLayoutSubviews method will know which page to navigate to (for example if the screen was portrait when you left, then you changed to landscape, and navigate back, then viewDidLayoutSubviews will need to change all the sizes of the views, but still know what page to set the offset to)
Expand All @@ -522,6 +532,18 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
}
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)]) {
[self.scrollViewDelegate scrollViewWillBeginDragging:scrollView];
}
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if ([self.scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndDragging:willDecelerate:)]) {
[self.scrollViewDelegate scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
}
}

#pragma mark property setters - for when need to do fancy things as well as set the value

-(void)setDataSource:(id<TTSlidingPagesDataSource>)dataSource{
Expand Down

0 comments on commit faae579

Please sign in to comment.