Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
improve header page controller
Browse files Browse the repository at this point in the history
  • Loading branch information
steven851007 committed Oct 23, 2014
1 parent 952e1aa commit c65fb97
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>82993CBC00D95B35FF12724787CF9820B327ED66</key>
<string>https://github.com/xhzengAIB/HAPaperViewController.git</string>
<string>ssh://github.com/steven851007/HAPaperViewController.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Paper.xcodeproj/project.xcworkspace</string>
<string>Paper.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>82993CBC00D95B35FF12724787CF9820B327ED66</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/xhzengAIB/HAPaperViewController.git</string>
<string>ssh://github.com/steven851007/HAPaperViewController.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
Expand Down
7 changes: 4 additions & 3 deletions Paper/HAPaperCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ -(void)viewDidLoad{

[super viewDidLoad];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:CELL_ID];
[self.collectionView setBackgroundColor:[UIColor clearColor]];

self.collectionView.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.topItem.title = @"";

[self.collectionView registerNib:[UINib nibWithNibName:NIB_NAME_HEADER bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];

[self.collectionView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
Expand Down Expand Up @@ -92,7 +93,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
withReuseIdentifier:@"header"
forIndexPath:indexPath];
__weak __typeof__(self) weakSelf = self;
self.header.didPagControllerChanged = ^(int newPageIndex){
self.header.didPagControllerChanged = ^(NSInteger newPageIndex){

weakSelf.count = arc4random_uniform(20) + 3;
[weakSelf.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
Expand Down
2 changes: 1 addition & 1 deletion Paper/HASectionHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

@interface HASectionHeader : UICollectionViewCell

@property (nonatomic, copy) void (^didPagControllerChanged)(int newPageIndex);
@property (nonatomic, copy) void (^didPagControllerChanged)(NSInteger newPageIndex);

@end
12 changes: 6 additions & 6 deletions Paper/HASectionHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ -(void)awakeFromNib{
[self.subTitleLabel.layer setShadowOpacity:0.6];
}

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

CGFloat pageWidth = scrollView.frame.size.width;
float fractionalPage = scrollView.contentOffset.x / pageWidth;
NSInteger page = lround(fractionalPage);
if (self.pageControl.currentPage != page) {
self.reflectedImage.image = [self.imageViews[page] image];
self.pageControl.currentPage = page;
NSInteger newPage = lround(fractionalPage);
if (self.pageControl.currentPage != newPage) {
self.reflectedImage.image = [self.imageViews[newPage] image];
self.pageControl.currentPage = newPage;

if (self.didPagControllerChanged) {
self.didPagControllerChanged(page);
self.didPagControllerChanged(newPage);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Paper/HAViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ @implementation HAViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"";
// Do any additional setup after loading the view, typically from a nib.
}

Expand Down

0 comments on commit c65fb97

Please sign in to comment.