Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
Header documentation and a little clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilter Cengiz committed Aug 29, 2013
1 parent 4cded27 commit 4ed3dd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 11 additions & 0 deletions ICViewPager/ICViewPager/ViewPagerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,39 @@ typedef enum {
@property id<ViewPagerDelegate> delegate;

// ViewPagerOptions
// Tab bar's height, defaults to 49.0
@property CGFloat tabHeight;
// Tab bar's offset from left, defaults to 56.0
@property CGFloat tabOffset;
// Any tab item's width, defaults to 128.0. To-do: make this dynamic
@property CGFloat tabWidth;

// 1.0: Top, 0.0: Bottom, changes tab bar's location in the screen
@property CGFloat tabLocation;

// Reload all tabs and contents
- (void)reloadData;

@end

@protocol ViewPagerDataSource <NSObject>

// Asks dataSource how many tabs will be
- (NSUInteger)numberOfTabsForViewPager:(ViewPagerController *)viewPager;
// Asks dataSource to give a view to display as a tab item
- (UIView *)viewPager:(ViewPagerController *)viewPager viewForTabAtIndex:(NSUInteger)index;
// The content for any tab. Return a view controller and ViewPager will use its view to show as content
- (UIViewController *)viewPager:(ViewPagerController *)viewPager contentForTabAtIndex:(NSUInteger)index;

@end

@protocol ViewPagerDelegate <NSObject>

@optional
// delegate object must implement this method if wants to be informed when a tab changes
- (void)viewPager:(ViewPagerController *)viewPager didChangeTabToIndex:(NSUInteger)index;
// Every time - reloadData called, ViewPager will ask its delegate for option values
// So you don't have to set options from ViewPager itself
- (CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerOption)option withDefault:(CGFloat)value;

@end
12 changes: 2 additions & 10 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ - (IBAction)handlePanGesture:(id)sender {
UIPanGestureRecognizer *panGestureRecognizer = (UIPanGestureRecognizer *)sender;

CGPoint translation = [panGestureRecognizer translationInView:self.pageViewController.view];
NSLog(@"X: %f Y: %f", translation.x, translation.y);
// NSLog(@"X: %f Y: %f", translation.x, translation.y);

// Bring tab to active position
UIView *tabView = [self tabViewAtIndex:self.activeTabIndex];
Expand All @@ -97,19 +97,11 @@ - (IBAction)handleTapGesture:(id)sender {
direction:UIPageViewControllerNavigationDirectionReverse
animated:YES
completion:nil];
NSLog(@"%@", self.pageViewController.viewControllers);
for (UIViewController *viewController in self.pageViewController.viewControllers) {
NSLog(@"Index: %i", [self indexForViewController:viewController]);
}
} else if (index > self.activeTabIndex) {
[_pageViewController setViewControllers:@[[self viewControllerAtIndex:index]]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
NSLog(@"%@", self.pageViewController.viewControllers);
for (UIViewController *viewController in self.pageViewController.viewControllers) {
NSLog(@"Index: %i", [self indexForViewController:viewController]);
}
}

// Set active tab
Expand Down Expand Up @@ -280,7 +272,7 @@ - (UIViewController *)pageViewController:(UIPageViewController *)pageViewControl

#pragma mark - UIPageViewControllerDelegate
- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers {
NSLog(@"willTransitionToViewController: %i", [self indexForViewController:[pendingViewControllers objectAtIndex:0]]);
// NSLog(@"willTransitionToViewController: %i", [self indexForViewController:[pendingViewControllers objectAtIndex:0]]);
}
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed {

Expand Down

0 comments on commit 4ed3dd4

Please sign in to comment.