Skip to content

Commit b285619

Browse files
author
Jose Alcalá Correa
committed
Add example with tabs on the bottom
1 parent 9a95ea2 commit b285619

File tree

14 files changed

+108
-22
lines changed

14 files changed

+108
-22
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
C0752A5D1C95EF9C000543E3 /* GSKTwitterExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0752A5C1C95EF9C000543E3 /* GSKTwitterExampleViewController.m */; };
4242
C086E0031C846309002A54C1 /* GSKExampleNavigationBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C086E0021C846309002A54C1 /* GSKExampleNavigationBarViewController.m */; };
4343
C086E00A1C846C5E002A54C1 /* GSKExampleBaseTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C086E0091C846C5E002A54C1 /* GSKExampleBaseTableViewController.m */; };
44+
C08935C61DD5D96B00BA8078 /* TabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C08935C51DD5D96B00BA8078 /* TabBarViewController.swift */; };
4445
C090247B1C901F2300264C0D /* GSKVisibleSectionHeadersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C090247A1C901F2300264C0D /* GSKVisibleSectionHeadersViewController.m */; };
4546
C0F6F5B71CA9571F00026142 /* GSKTwitterStretchyHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0F6F5B61CA9571F00026142 /* GSKTwitterStretchyHeaderView.m */; };
4647
/* End PBXBuildFile section */
@@ -119,6 +120,7 @@
119120
C086E0021C846309002A54C1 /* GSKExampleNavigationBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GSKExampleNavigationBarViewController.m; sourceTree = "<group>"; };
120121
C086E0081C846C5E002A54C1 /* GSKExampleBaseTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSKExampleBaseTableViewController.h; sourceTree = "<group>"; };
121122
C086E0091C846C5E002A54C1 /* GSKExampleBaseTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GSKExampleBaseTableViewController.m; sourceTree = "<group>"; };
123+
C08935C51DD5D96B00BA8078 /* TabBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarViewController.swift; sourceTree = "<group>"; };
122124
C09024791C901F2300264C0D /* GSKVisibleSectionHeadersViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSKVisibleSectionHeadersViewController.h; sourceTree = "<group>"; };
123125
C090247A1C901F2300264C0D /* GSKVisibleSectionHeadersViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GSKVisibleSectionHeadersViewController.m; sourceTree = "<group>"; };
124126
C0F6F5B51CA9571F00026142 /* GSKTwitterStretchyHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSKTwitterStretchyHeaderView.h; sourceTree = "<group>"; };
@@ -252,12 +254,6 @@
252254
C086E0071C846C4F002A54C1 /* Base view controllers */,
253255
C086E0001C8462D6002A54C1 /* Data source */,
254256
C086DFFF1C8462C9002A54C1 /* Cells */,
255-
C03FC4E51C81B2FE0015FAAA /* UINavigationController+Transparency.h */,
256-
C03FC4E61C81B2FE0015FAAA /* UINavigationController+Transparency.m */,
257-
C03FC4E81C81B3250015FAAA /* GSKExampleCollectionViewController.h */,
258-
C03FC4E91C81B3250015FAAA /* GSKExampleCollectionViewController.m */,
259-
C03FC4EA1C81B3250015FAAA /* GSKExampleTableViewController.h */,
260-
C03FC4EB1C81B3250015FAAA /* GSKExampleTableViewController.m */,
261257
C03FC4FA1C8348150015FAAA /* GSKExampleTabsViewController.h */,
262258
C03FC4FB1C8348150015FAAA /* GSKExampleTabsViewController.m */,
263259
C086E0011C846309002A54C1 /* GSKExampleNavigationBarViewController.h */,
@@ -269,6 +265,7 @@
269265
C0752A5B1C95EF9C000543E3 /* GSKTwitterExampleViewController.h */,
270266
C0752A5C1C95EF9C000543E3 /* GSKTwitterExampleViewController.m */,
271267
82469C511CF3A0D600D3335A /* ScalableLabelViewController.swift */,
268+
C08935C51DD5D96B00BA8078 /* TabBarViewController.swift */,
272269
);
273270
name = "View Controllers";
274271
sourceTree = "<group>";
@@ -330,6 +327,12 @@
330327
children = (
331328
C086E0081C846C5E002A54C1 /* GSKExampleBaseTableViewController.h */,
332329
C086E0091C846C5E002A54C1 /* GSKExampleBaseTableViewController.m */,
330+
C03FC4E51C81B2FE0015FAAA /* UINavigationController+Transparency.h */,
331+
C03FC4E61C81B2FE0015FAAA /* UINavigationController+Transparency.m */,
332+
C03FC4E81C81B3250015FAAA /* GSKExampleCollectionViewController.h */,
333+
C03FC4E91C81B3250015FAAA /* GSKExampleCollectionViewController.m */,
334+
C03FC4EA1C81B3250015FAAA /* GSKExampleTableViewController.h */,
335+
C03FC4EB1C81B3250015FAAA /* GSKExampleTableViewController.m */,
333336
);
334337
name = "Base view controllers";
335338
sourceTree = "<group>";
@@ -365,7 +368,7 @@
365368
attributes = {
366369
CLASSPREFIX = GSK;
367370
LastSwiftUpdateCheck = 0730;
368-
LastUpgradeCheck = 0720;
371+
LastUpgradeCheck = 0810;
369372
ORGANIZATIONNAME = "Jose Alcalá Correa";
370373
TargetAttributes = {
371374
6003F589195388D20070C39A = {
@@ -464,6 +467,7 @@
464467
C03FC4F41C820C9C0015FAAA /* GSKNibStretchyHeaderView.m in Sources */,
465468
C066207A1C87311000F1AEF5 /* GSKAirbnbExampleViewController.m in Sources */,
466469
C03FC5031C8348150015FAAA /* GSKExampleTabsViewController.m in Sources */,
470+
C08935C61DD5D96B00BA8078 /* TabBarViewController.swift in Sources */,
467471
C0752A5D1C95EF9C000543E3 /* GSKTwitterExampleViewController.m in Sources */,
468472
C090247B1C901F2300264C0D /* GSKVisibleSectionHeadersViewController.m in Sources */,
469473
6003F59E195388D20070C39A /* GSKAppDelegate.m in Sources */,
@@ -517,14 +521,19 @@
517521
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
518522
CLANG_WARN_EMPTY_BODY = YES;
519523
CLANG_WARN_ENUM_CONVERSION = YES;
524+
CLANG_WARN_INFINITE_RECURSION = YES;
520525
CLANG_WARN_INT_CONVERSION = YES;
521526
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
527+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
528+
CLANG_WARN_UNREACHABLE_CODE = YES;
522529
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
523530
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
524531
COPY_PHASE_STRIP = NO;
532+
ENABLE_STRICT_OBJC_MSGSEND = YES;
525533
ENABLE_TESTABILITY = YES;
526534
GCC_C_LANGUAGE_STANDARD = gnu99;
527535
GCC_DYNAMIC_NO_PIC = NO;
536+
GCC_NO_COMMON_BLOCKS = YES;
528537
GCC_OPTIMIZATION_LEVEL = 0;
529538
GCC_PREPROCESSOR_DEFINITIONS = (
530539
"DEBUG=1",

Example/GSKStretchyHeaderView/Example-Bridging-Header.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77
#import "GSKExampleBaseTableViewController.h"
88
#import "UINavigationController+Transparency.h"
99
#import "UIView+GSKLayoutHelper.h"
10+
11+
12+
#import "GSKExampleData.h"
13+
#import "GSKExampleTableViewController.h"
14+
#import "GSKExampleCollectionViewController.h"
15+
#import "GSKVisibleSectionHeadersViewController.h"
16+
#import "GSKAirbnbExampleViewController.h"

Example/GSKStretchyHeaderView/GSKExampleBaseTableViewController.m

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,26 @@ @interface GSKExampleBaseTableViewController ()
99

1010
@implementation GSKExampleBaseTableViewController
1111

12+
- (instancetype)init {
13+
self = [super init];
14+
if (self) {
15+
self.title = [self defaultTitle];
16+
}
17+
return self;
18+
}
19+
1220
- (void)viewDidLoad {
1321
[super viewDidLoad];
14-
22+
1523
self.automaticallyAdjustsScrollViewInsets = NO;
24+
UIEdgeInsets contentInset = self.tableView.contentInset;
25+
if (self.navigationController) {
26+
contentInset.top = 64;
27+
}
28+
if (self.tabBarController) {
29+
contentInset.bottom = 44;
30+
}
31+
self.tableView.contentInset = contentInset;
1632

1733
_stretchyHeaderView = [self loadStretchyHeaderView];
1834
[self.tableView addSubview:self.stretchyHeaderView];
@@ -21,6 +37,14 @@ - (void)viewDidLoad {
2137
[self.dataSource registerForTableView:self.tableView];
2238
}
2339

40+
- (NSString *)defaultTitle {
41+
NSString *className = NSStringFromClass(self.class);
42+
NSString *lastComponent = [className componentsSeparatedByString:@"."].lastObject;
43+
NSString *title = [lastComponent stringByReplacingOccurrencesOfString:@"ViewController" withString:@""];
44+
title = [title stringByReplacingOccurrencesOfString:@"Example" withString:@""];
45+
title = [title stringByReplacingOccurrencesOfString:@"GSK" withString:@""];
46+
return title;
47+
}
2448

2549
- (GSKStretchyHeaderView *)loadStretchyHeaderView {
2650
NSAssert(NO, @"please override %@", NSStringFromSelector(_cmd));
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
@import UIKit;
22
#import "GSKExampleData.h"
33

4+
NS_ASSUME_NONNULL_BEGIN
5+
46
@interface GSKExampleCollectionViewController : UICollectionViewController
57

68
- (instancetype)initWithData:(GSKExampleData *)data;
79

810
@end
11+
12+
NS_ASSUME_NONNULL_END

Example/GSKStretchyHeaderView/GSKExampleCollectionViewController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#import "UINavigationController+Transparency.h"
44
#import "GSKExampleDataSource.h"
55

6+
NS_ASSUME_NONNULL_BEGIN
7+
68
static const NSUInteger kNumberOfRows = 100;
79

810
@interface GSKExampleCollectionViewController () <UICollectionViewDelegateFlowLayout>
@@ -63,3 +65,5 @@ - (CGSize)collectionView:(UICollectionView *)collectionView
6365
}
6466

6567
@end
68+
69+
NS_ASSUME_NONNULL_END

Example/GSKStretchyHeaderView/GSKExampleData.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ NS_ASSUME_NONNULL_BEGIN
55
@interface GSKExampleData : NSObject
66

77
@property (nonatomic, readonly) NSString *title;
8-
@property (nonatomic, readonly) Class viewControllerClass;
9-
@property (nonatomic, readonly) Class headerViewClass;
10-
@property (nonatomic, readonly) NSString *nibName;
8+
@property (nullable, nonatomic, readonly) Class viewControllerClass;
9+
@property (nullable, nonatomic, readonly) Class headerViewClass;
10+
@property (nullable, nonatomic, readonly) NSString *nibName;
1111
@property (nonatomic) BOOL navigationBarVisible; // default NO
1212
@property (nonatomic) CGFloat headerViewInitialHeight; // default 240
1313

Example/GSKStretchyHeaderView/GSKExampleData.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@interface GSKExampleData ()
44

55
@property (nonatomic) NSString *title;
6-
@property (nonatomic) Class viewControllerClass;
7-
@property (nonatomic) Class headerViewClass;
8-
@property (nonatomic) NSString *nibName;
6+
@property (nullable, nonatomic) Class viewControllerClass;
7+
@property (nullable, nonatomic) Class headerViewClass;
8+
@property (nullable, nonatomic) NSString *nibName;
99

1010
@end
1111

Example/GSKStretchyHeaderView/GSKExampleListViewController.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,19 @@ - (void)viewDidLoad {
4747
GSKExampleData *nib = [GSKExampleData dataWithTitle:@"From a XIB file (+ expansion modes)"
4848
headerViewNibName:@"GSKNibStretchyHeaderView"];
4949

50-
GSKExampleData *tabs = [GSKExampleData dataWithTitle:@"With tabs"
50+
GSKExampleData *tabs = [GSKExampleData dataWithTitle:@"With tabs on top"
5151
viewControllerClass:[GSKExampleTabsViewController class]];
52-
52+
5353
GSKExampleData *navBar = [GSKExampleData dataWithTitle:@"Below the navigation bar"
5454
viewControllerClass:[GSKExampleNavigationBarViewController class]];
55+
56+
GSKExampleData *tabBarViewController = [GSKExampleData dataWithTitle:@"Tab bar view controller"
57+
viewControllerClass:[TabBarViewController class]];
5558

5659
GSKExampleData *visibleHeaders = [GSKExampleData dataWithTitle:@"Visible section headers"
5760
viewControllerClass:[GSKVisibleSectionHeadersViewController class]];
5861

59-
self.exampleDatas = @[airbnb, twitter, spoty, scalableLabel, firstExample, nib, tabs, navBar, visibleHeaders];
62+
self.exampleDatas = @[airbnb, twitter, spoty, scalableLabel, firstExample, nib, tabs, navBar, tabBarViewController, visibleHeaders];
6063
}
6164

6265
- (void)viewWillAppear:(BOOL)animated {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#import "GSKExampleBaseTableViewController.h"
22
#import "GSKExampleData.h"
33

4+
NS_ASSUME_NONNULL_BEGIN
5+
46
@interface GSKExampleTableViewController : GSKExampleBaseTableViewController
57

68
@property (nonatomic, readonly) GSKExampleData *data;
79

810
- (instancetype)initWithData:(GSKExampleData *)data;
911

1012
@end
13+
14+
NS_ASSUME_NONNULL_END

Example/GSKStretchyHeaderView/GSKExampleTableViewController.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#import "GSKExampleTableViewController.h"
22
#import "UINavigationController+Transparency.h"
33

4+
NS_ASSUME_NONNULL_BEGIN
5+
46
@implementation GSKExampleTableViewController
57

68
- (instancetype)initWithData:(GSKExampleData *)data {
@@ -25,14 +27,19 @@ - (GSKStretchyHeaderView *)loadStretchyHeaderView {
2527

2628
if (self.data.headerViewClass) {
2729
headerView = [[self.data.headerViewClass alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, self.data.headerViewInitialHeight)];
28-
} else {
30+
} else if (self.data.nibName) {
2931
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:self.data.nibName
3032
owner:self
3133
options:nil];
3234
headerView = nibViews.firstObject;
35+
} else {
36+
[NSException raise:@"Can't initialise header view"
37+
format:@"You must provide a header view in GSKExampleData instances"];
3338
}
3439

3540
return headerView;
3641
}
3742

3843
@end
44+
45+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)