Skip to content

Commit

Permalink
Add delegate methods:
Browse files Browse the repository at this point in the history
```
- (void)segmentedPager:(MXSegmentedPager *)segmentedPager willDisplayPage:(UIView *)page atIndex:(NSInteger)index;
- (void)segmentedPager:(MXSegmentedPager *)segmentedPager didEndDisplayingPage:(UIView *)page atIndex:(NSInteger)index;
```
  • Loading branch information
maxep committed May 6, 2017
1 parent e52aa42 commit c6352b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MXSegmentedPager/MXSegmentedPager.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ typedef NS_ENUM(NSInteger, MXSegmentedControlPosition) {
*/
- (void)segmentedPager:(MXSegmentedPager *)segmentedPager didSelectViewWithIndex:(NSInteger)index;

/**
Tells the delegate the segmented pager is about to draw a page for a particular index.
A segmented page view sends this message to its delegate just before it uses page to draw a index, thereby permitting the delegate to customize the page object before it is displayed.
@param segmentedPager The segmented-pager object informing the delegate of this impending event.
@param page A page view object that segmented-pager is going to use when drawing the index.
@param index An index locating the page in pagerView.
*/
- (void)segmentedPager:(MXSegmentedPager *)segmentedPager willDisplayPage:(UIView *)page atIndex:(NSInteger)index;

/**
Tells the delegate that the specified page was removed from the pager.
Use this method to detect when a page is removed from a pager view, as opposed to monitoring the view itself to see when it appears or disappears.
@param segmentedPager The segmented-pager object that removed the view.
@param page The page that was removed.
@param index The index of the page.
*/
- (void)segmentedPager:(MXSegmentedPager *)segmentedPager didEndDisplayingPage:(UIView *)page atIndex:(NSInteger)index;

/**
Asks the delegate to return the height of the segmented control in the segmented-pager.
If the delegate doesn’t implement this method, 44 is assumed.
Expand Down
12 changes: 12 additions & 0 deletions MXSegmentedPager/MXSegmentedPager.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ - (void)pagerView:(MXPagerView *)pagerView didMoveToPage:(UIView *)page atIndex:
[self changedToIndex:index];
}

- (void)pagerView:(MXPagerView *)pagerView willDisplayPage:(UIView *)page atIndex:(NSInteger)index {
if ([self.delegate respondsToSelector:@selector(segmentedPager:willDisplayPage:atIndex:)]) {
[self.delegate segmentedPager:self willDisplayPage:page atIndex:index];
}
}

- (void)pagerView:(MXPagerView *)pagerView didEndDisplayingPage:(UIView *)page atIndex:(NSInteger)index {
if ([self.delegate respondsToSelector:@selector(segmentedPager:didEndDisplayingPage:atIndex:)]) {
[self.delegate segmentedPager:self didEndDisplayingPage:page atIndex:index];
}
}

#pragma mark <MXPagerViewDataSource>

- (NSInteger)numberOfPagesInPagerView:(MXPagerView *)pagerView {
Expand Down

0 comments on commit c6352b2

Please sign in to comment.