Skip to content

Commit

Permalink
【update CocoaPods version to 1.5.1】
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsic committed Jul 9, 2018
1 parent 5bcd57c commit 0ae11e7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion SGPagingView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SGPagingView'
s.version = '1.5.0'
s.version = '1.5.1'
s.summary = 'A powerful and easy to use segment control'
s.homepage = 'https://github.com/kingsic/SGPagingView'
s.license = 'MIT'
Expand Down
8 changes: 8 additions & 0 deletions SGPagingView/SGPageContent/SGPageContentCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ @interface SGPageContentCollectionView () <UICollectionViewDataSource, UICollect
@property (nonatomic, assign) NSInteger startOffsetX;
/// 记录加载的上个子控制器的下标
@property (nonatomic, assign) NSInteger previousCVCIndex;
/// 标记内容滚动
@property (nonatomic, assign) BOOL isScrll;
@end

@implementation SGPageContentCollectionView
Expand Down Expand Up @@ -109,12 +111,14 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
#pragma mark - - - UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
_startOffsetX = scrollView.contentOffset.x;
_isScrll = YES;
if (self.delegatePageContentCollectionView && [self.delegatePageContentCollectionView respondsToSelector:@selector(pageContentCollectionViewWillBeginDragging)]) {
[self.delegatePageContentCollectionView pageContentCollectionViewWillBeginDragging];
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
_isScrll = NO;
CGFloat offsetX = scrollView.contentOffset.x;
// 1、记录上个子控制器下标
_previousCVCIndex = offsetX / scrollView.frame.size.width;
Expand All @@ -129,6 +133,9 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (_isAnimated == YES && _isScrll == NO) {
return;
}
// 1、定义获取需要的数据
CGFloat progress = 0;
NSInteger originalIndex = 0;
Expand Down Expand Up @@ -172,6 +179,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
#pragma mark - - - 给外界提供的方法,获取 SGPageTitleView 选中按钮的下标
- (void)setPageContentCollectionViewCurrentIndex:(NSInteger)currentIndex {
CGFloat offsetX = currentIndex * self.collectionView.SG_width;
_startOffsetX = offsetX;
// 1、处理内容偏移
if (_previousCVCIndex != currentIndex) {
[self.collectionView setContentOffset:CGPointMake(offsetX, 0) animated:_isAnimated];
Expand Down
19 changes: 15 additions & 4 deletions SGPagingView/SGPageContent/SGPageContentScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ @interface SGPageContentScrollView () <UIScrollViewDelegate>
@property (nonatomic, weak) UIViewController *previousCVC;
/// 记录加载的上个子控制器的下标
@property (nonatomic, assign) NSInteger previousCVCIndex;
/// 标记内容滚动
@property (nonatomic, assign) BOOL isScrll;
@end

@implementation SGPageContentScrollView
Expand Down Expand Up @@ -83,12 +85,14 @@ - (UIScrollView *)scrollView {
#pragma mark - - - UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
_startOffsetX = scrollView.contentOffset.x;
_isScrll = YES;
if (self.delegatePageContentScrollView && [self.delegatePageContentScrollView respondsToSelector:@selector(pageContentScrollViewWillBeginDragging)]) {
[self.delegatePageContentScrollView pageContentScrollViewWillBeginDragging];
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
_isScrll = NO;
// 1、根据标题下标计算 pageContent 偏移量
CGFloat offsetX = scrollView.contentOffset.x;
// 2、切换子控制器的时候,执行上个子控制器的 viewWillDisappear 方法
Expand Down Expand Up @@ -126,6 +130,9 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (_isAnimated == YES && _isScrll == NO) {
return;
}
// 1、定义获取需要的数据
CGFloat progress = 0;
NSInteger originalIndex = 0;
Expand Down Expand Up @@ -168,12 +175,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {

#pragma mark - - - 给外界提供的方法,获取 SGPageTitleView 选中按钮的下标
- (void)setPageContentScrollViewCurrentIndex:(NSInteger)currentIndex {
// 1、切换子控制器的时候,执行上个子控制器的 viewWillDisappear 方法
// 1、根据标题下标计算 pageContent 偏移量
CGFloat offsetX = currentIndex * self.SG_width;

// 2、切换子控制器的时候,执行上个子控制器的 viewWillDisappear 方法
if (self.previousCVC != nil && _previousCVCIndex != currentIndex) {
[self.previousCVC beginAppearanceTransition:NO animated:NO];
}
// 2、根据标题下标计算 pageContent 偏移量
CGFloat offsetX = currentIndex * self.SG_width;

// 3、添加子控制器及子控制器的 view 到父控制器以及父控制器 view 中
if (_previousCVCIndex != currentIndex) {
UIViewController *childVC = self.childViewControllers[currentIndex];
Expand All @@ -195,7 +204,9 @@ - (void)setPageContentScrollViewCurrentIndex:(NSInteger)currentIndex {
}
// 3.2、记录上个子控制器下标
_previousCVCIndex = currentIndex;

// 3.3、重置 _startOffsetX
_startOffsetX = offsetX;

// 5、pageContentScrollView:index:
if (self.delegatePageContentScrollView && [self.delegatePageContentScrollView respondsToSelector:@selector(pageContentScrollView:index:)]) {
[self.delegatePageContentScrollView pageContentScrollView:self index:currentIndex];
Expand Down
2 changes: 1 addition & 1 deletion SGPagingView/SGPagingView.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// GitHub:https://github.com/kingsic
//
// SGPagingView.h
// Version 1.5.0
// Version 1.5.1
//
// Created by kingsic on 2016/10/6.
// Copyright © 2016年 kingsic. All rights reserved.
Expand Down
2 changes: 0 additions & 2 deletions SGPagingViewExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
3 changes: 1 addition & 2 deletions SGPagingViewExample/MainVC/DefaultZoomVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)setupPageView {

NSArray *titleArr = @[@"精选", @"电影", @"电视剧", @"综艺", @"NBA", @"娱乐", @"动漫", @"演唱会", @"VIP会员"];
SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
configure.showIndicator = NO;
// configure.showIndicator = NO;
configure.titleTextZoom = YES;
configure.titleTextZoomAdditionalPointSize = 0.3;
configure.titleAdditionalWidth = 30;
Expand All @@ -69,7 +69,6 @@ - (void)setupPageView {
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), self.view.frame.size.width, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
_pageContentCollectionView.delegatePageContentCollectionView = self;
[self.view addSubview:_pageContentCollectionView];
_pageContentCollectionView.isAnimated = YES;
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
Expand Down
11 changes: 9 additions & 2 deletions SGPagingViewExample/NavigationBar/Controller/NavigationBarVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ - (void)setupNavigationBar {
ChildVCNine *nineVC = [[ChildVCNine alloc] init];
NSArray *childArr = @[oneVC, twoVC, threeVC, fourVC, fiveVC, sixVC, sevenVC, eightVC, nineVC];
/// pageContentCollectionView
CGFloat ContentCollectionViewHeight = self.view.frame.size.height - 64;
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
CGFloat pageTitleViewY = 0;
if (statusHeight == 20.0) {
pageTitleViewY = 64;
} else {
pageTitleViewY = 88;
}
CGFloat ContentCollectionViewHeight = self.view.frame.size.height - pageTitleViewY;
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, pageTitleViewY, self.view.frame.size.width, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
_pageContentCollectionView.delegatePageContentCollectionView = self;
[self.view addSubview:_pageContentCollectionView];
}
Expand Down

0 comments on commit 0ae11e7

Please sign in to comment.