From ff67d2b0a084f816d8060576134389c90b64a994 Mon Sep 17 00:00:00 2001 From: Mazyad Alabduljaleel Date: Tue, 20 Oct 2015 19:41:36 -0700 Subject: [PATCH] Added collectionView demo Has the problem described in #93 --- .../project.pbxproj | 14 ++++ .../Base.lproj/Main.storyboard | 60 ++++++++++++++- .../TLYCollectionViewController.h | 13 ++++ .../TLYCollectionViewController.m | 74 +++++++++++++++++++ 4 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.h create mode 100644 TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.m diff --git a/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.pbxproj b/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.pbxproj index b633b7b..900d0d1 100644 --- a/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.pbxproj +++ b/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 8262C8551BD730DD00B610A0 /* TLYCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8262C8541BD730DD00B610A0 /* TLYCollectionViewController.m */; settings = {ASSET_TAGS = (); }; }; 8268FA02194C926F004EC0E4 /* TLYShyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8268FA01194C926F004EC0E4 /* TLYShyViewController.m */; }; 8268FA13194DBA58004EC0E4 /* TLYShyNavBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8268FA12194DBA58004EC0E4 /* TLYShyNavBarManager.m */; }; 828F57201949C37B009EB8DD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 828F571F1949C37B009EB8DD /* Foundation.framework */; }; @@ -40,6 +41,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 8262C8531BD730DD00B610A0 /* TLYCollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLYCollectionViewController.h; sourceTree = ""; }; + 8262C8541BD730DD00B610A0 /* TLYCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TLYCollectionViewController.m; sourceTree = ""; }; 8268FA00194C926F004EC0E4 /* TLYShyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLYShyViewController.h; sourceTree = ""; }; 8268FA01194C926F004EC0E4 /* TLYShyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TLYShyViewController.m; sourceTree = ""; }; 8268FA11194DBA58004EC0E4 /* TLYShyNavBarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLYShyNavBarManager.h; sourceTree = ""; }; @@ -97,6 +100,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 8262C8521BD730CB00B610A0 /* CollectionView */ = { + isa = PBXGroup; + children = ( + 8262C8531BD730DD00B610A0 /* TLYCollectionViewController.h */, + 8262C8541BD730DD00B610A0 /* TLYCollectionViewController.m */, + ); + name = CollectionView; + sourceTree = ""; + }; 828F57131949C37B009EB8DD = { isa = PBXGroup; children = ( @@ -131,6 +143,7 @@ 828F57251949C37B009EB8DD /* TLYShyNavBarDemo */ = { isa = PBXGroup; children = ( + 8262C8521BD730CB00B610A0 /* CollectionView */, 828F572E1949C37B009EB8DD /* TLYAppDelegate.h */, 828F572F1949C37B009EB8DD /* TLYAppDelegate.m */, 828F57311949C37B009EB8DD /* Main.storyboard */, @@ -305,6 +318,7 @@ 8268FA02194C926F004EC0E4 /* TLYShyViewController.m in Sources */, 829FEE001957DF620017E186 /* NSObject+TLYSwizzlingHelpers.m in Sources */, 828F57361949C37B009EB8DD /* TLYViewController.m in Sources */, + 8262C8551BD730DD00B610A0 /* TLYCollectionViewController.m in Sources */, 828F572C1949C37B009EB8DD /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/TLYShyNavBarDemo/TLYShyNavBarDemo/Base.lproj/Main.storyboard b/TLYShyNavBarDemo/TLYShyNavBarDemo/Base.lproj/Main.storyboard index 809e862..50c85e7 100644 --- a/TLYShyNavBarDemo/TLYShyNavBarDemo/Base.lproj/Main.storyboard +++ b/TLYShyNavBarDemo/TLYShyNavBarDemo/Base.lproj/Main.storyboard @@ -3,6 +3,7 @@ + @@ -183,15 +184,15 @@ - + - + - + + + @@ -283,6 +287,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.h b/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.h new file mode 100644 index 0000000..99f7287 --- /dev/null +++ b/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.h @@ -0,0 +1,13 @@ +// +// TLYCollectionViewController.h +// TLYShyNavBarDemo +// +// Created by Mazyad Alabduljaleel on 10/20/15. +// Copyright © 2015 Telly, Inc. All rights reserved. +// + +#import + +@interface TLYCollectionViewController : UICollectionViewController + +@end diff --git a/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.m b/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.m new file mode 100644 index 0000000..3f6398e --- /dev/null +++ b/TLYShyNavBarDemo/TLYShyNavBarDemo/TLYCollectionViewController.m @@ -0,0 +1,74 @@ +// +// TLYCollectionViewController.m +// TLYShyNavBarDemo +// +// Created by Mazyad Alabduljaleel on 10/20/15. +// Copyright © 2015 Telly, Inc. All rights reserved. +// + +#import "TLYCollectionViewController.h" + +@interface TLYCollectionViewController () + +@property (nonatomic, strong) NSArray *data; + +@end + +@implementation TLYCollectionViewController + +static NSString * const reuseIdentifier = @"Cell"; + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.data = @[@"No Game No Life", + @"Ookami Kodomo no Ame to Yuki", + @"Owari no Seraph", + @"Prince of Tennis", + @"Psycho-Pass", + @"Psycho-Pass 2", + @"School Rumble", + @"Sen to Chihiro no Kamikakushi", + @"Shijou Saikyou no Deshi Kenichi", + @"Shingeki no Kyojin", + @"Soul Eater", + @"Steins;Gate", + @"Summer Wars", + @"Sword Art Online", + @"Sword Art Online II", + @"Tenkuu no Shiro Laputa", + @"Toki wo Kakeru Shoujo", + @"Tokyo Ghoul", + @"Tonari no Totoro", + @"Uchuu Kyoudai", + @"Yakitate!! Japan", + @"Zankyou ", + ]; + + UIView *view = view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 40.f)]; + view.backgroundColor = [UIColor redColor]; + + + /* Library code */ + self.shyNavBarManager.scrollView = self.collectionView; + /* Can then be remove by setting the ExtensionView to nil */ + [self.shyNavBarManager setExtensionView:view]; +} + +#pragma mark + +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.data.count; +} + +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + + UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; + + UILabel *label = (id)[cell viewWithTag:777]; + label.text = self.data[indexPath.item]; + + return cell; +} + +@end