Skip to content

Commit

Permalink
UIScrollSlidingPages - Add delegate callback for scroll event to give…
Browse files Browse the repository at this point in the history
… a indication of a paging event(helps in the scenario when users want feedback on the scroll)
  • Loading branch information
johndoran committed Dec 6, 2013
1 parent 2eae9b9 commit 211cb58
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions UIScrollSlidingPages.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
37989C431852727A00A97623 /* TTSliddingPageDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TTSliddingPageDelegate.h; sourceTree = "<group>"; };
9F2035E31706475B00438E50 /* diagmonds.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = diagmonds.png; sourceTree = "<group>"; };
9F2035E41706475B00438E50 /* diagmonds_@2X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "diagmonds_@2X.png"; sourceTree = "<group>"; };
9F2035E51706475B00438E50 /* readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = readme.txt; sourceTree = "<group>"; };
Expand Down Expand Up @@ -185,6 +186,7 @@
9F602A66171E083F00088A9C /* TTBlackTriangle.m */,
9FFDC5CA1722EEA1002A5689 /* TTScrollViewWrapper.h */,
9FFDC5CB1722EEA1002A5689 /* TTScrollViewWrapper.m */,
37989C431852727A00A97623 /* TTSliddingPageDelegate.h */,
);
path = Source;
sourceTree = "<group>";
Expand Down
3 changes: 2 additions & 1 deletion UIScrollViewSlidingPages/Demo/TTViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

#import <UIKit/UIKit.h>
#import "TTSlidingPagesDataSource.h"
#import "TTSliddingPageDelegate.h"

@interface TTViewController : UIViewController<TTSlidingPagesDataSource>{
@interface TTViewController : UIViewController<TTSlidingPagesDataSource, TTSliddingPageDelegate>{
}

@end
6 changes: 6 additions & 0 deletions UIScrollViewSlidingPages/Demo/TTViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,10 @@ -(TTSlidingPageTitle *)titleForSlidingPagesViewController:(TTScrollSlidingPagesC
// }
//}

#pragma mark - delegate
-(void)didScrollToViewAtIndex:(NSUInteger)index
{
NSLog(@"scrolled to view");
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#import <UIKit/UIKit.h>
#import "TTSlidingPagesDataSource.h"
#import "TTSliddingPageDelegate.h"

@class TTScrollViewWrapper;

@interface TTScrollSlidingPagesController : UIViewController<UIScrollViewDelegate>{
Expand All @@ -52,7 +54,9 @@



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

@property (nonatomic, weak) id<TTSliddingPageDelegate> delegate;

/** @property titleScrollerHidden
* @brief Whether the title scroller bar is hidden or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
topScrollView.delegate = nil;
topScrollView.contentOffset = CGPointMake(topXPosition, 0);
topScrollView.delegate = self;

//call the delegate to tell him you've scrolled to another page
if([self.delegate respondsToSelector:@selector(didScrollToViewAtIndex:)]){
[self.delegate didScrollToViewAtIndex:currentPage];
}
}

}
Expand Down
15 changes: 15 additions & 0 deletions UIScrollViewSlidingPages/Source/TTSliddingPageDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// TTSliddingPageDelegate.h
// UIScrollSlidingPages
//
// Created by John Doran on 06/12/2013.
// Copyright (c) 2013 Thomas Thorpe. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol TTSliddingPageDelegate <NSObject>

-(void)didScrollToViewAtIndex:(NSUInteger)index;

@end

0 comments on commit 211cb58

Please sign in to comment.