Skip to content

Commit

Permalink
Add SYPageView
Browse files Browse the repository at this point in the history
This will be necessary for page reuse once that is implemented.
  • Loading branch information
soffes committed Mar 9, 2012
1 parent 731489c commit 86890e5
Show file tree
Hide file tree
Showing 21 changed files with 268 additions and 120 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
.DS_Store
*xcuserdata/
*build/
*.mode1v3
*.pbxuser
*.xcworkspace
*.moved-aside/
*.zip
13 changes: 13 additions & 0 deletions Example/Classes/PEPageView.h
@@ -0,0 +1,13 @@
//
// PEPageView.h
// Paginator Example
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

@interface PEPageView : SYPageView

@property (nonatomic, strong, readonly) UILabel *textLabel;

@end
29 changes: 29 additions & 0 deletions Example/Classes/PEPageView.m
@@ -0,0 +1,29 @@
//
// PEPageView.m
// Paginator Example
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

#import "PEPageView.h"

@implementation PEPageView

@synthesize textLabel = _textLabel;

- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithReuseIdentifier:reuseIdentifier])) {
self.backgroundColor = [UIColor colorWithWhite:0.2f alpha:1.0f];

_textLabel = [[UILabel alloc] initWithFrame:self.bounds];
_textLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_textLabel.backgroundColor = [UIColor clearColor];
_textLabel.textAlignment = UITextAlignmentCenter;
_textLabel.textColor = [UIColor whiteColor];
[self addSubview:_textLabel];
}
return self;
}

@end
26 changes: 26 additions & 0 deletions Example/Classes/PERootViewController.m
Expand Up @@ -7,12 +7,38 @@
//

#import "PERootViewController.h"
#import "PEPageView.h"

@implementation PERootViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Paginator";
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

self.view.backgroundColor = [UIColor blackColor];
self.paginatorView.pageGap = 30.0f;
}


#pragma mark - SYPaginatorViewDataSource

- (NSUInteger)numberOfPagesForPaginatorView:(SYPaginatorView *)paginator {
return 10;
}


- (UIView *)paginatorView:(SYPaginatorView *)paginator viewForPage:(NSUInteger)page {
static NSString *identifier = @"identifier";

PEPageView *view = [paginator dequeueReusableViewWithIdentifier:identifier];
if (!view) {
view = [[PEPageView alloc] initWithReuseIdentifier:identifier];
}

view.textLabel.text = [NSString stringWithFormat:@"Page %i", page + 1];

return view;
}

@end
6 changes: 6 additions & 0 deletions Example/Paginator Example.xcodeproj/project.pbxproj
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
B275DFCE1509657000D6E7C1 /* PERootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B275DFCD1509656F00D6E7C1 /* PERootViewController.m */; };
B275DFF715097FD000D6E7C1 /* PEPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = B275DFF615097FD000D6E7C1 /* PEPageView.m */; };
B2C4DF731509622800ABF21F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2C4DF721509622800ABF21F /* UIKit.framework */; };
B2C4DF751509622800ABF21F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2C4DF741509622800ABF21F /* Foundation.framework */; };
B2C4DF771509622800ABF21F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2C4DF761509622800ABF21F /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -36,6 +37,8 @@
/* Begin PBXFileReference section */
B275DFCC1509656F00D6E7C1 /* PERootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PERootViewController.h; sourceTree = "<group>"; };
B275DFCD1509656F00D6E7C1 /* PERootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PERootViewController.m; sourceTree = "<group>"; };
B275DFF515097FD000D6E7C1 /* PEPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPageView.h; sourceTree = "<group>"; };
B275DFF615097FD000D6E7C1 /* PEPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPageView.m; sourceTree = "<group>"; };
B2C4DF6E1509622800ABF21F /* Paginator Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Paginator Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
B2C4DF721509622800ABF21F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
B2C4DF741509622800ABF21F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -100,6 +103,8 @@
B2C4DF90150962AD00ABF21F /* PEAppDelegate.m */,
B275DFCC1509656F00D6E7C1 /* PERootViewController.h */,
B275DFCD1509656F00D6E7C1 /* PERootViewController.m */,
B275DFF515097FD000D6E7C1 /* PEPageView.h */,
B275DFF615097FD000D6E7C1 /* PEPageView.m */,
);
path = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -211,6 +216,7 @@
B2C4DF96150962AD00ABF21F /* PEAppDelegate.m in Sources */,
B2C4DF97150962AD00ABF21F /* main.m in Sources */,
B275DFCE1509657000D6E7C1 /* PERootViewController.m in Sources */,
B275DFF715097FD000D6E7C1 /* PEPageView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions Example/Resources/Paginator Example-Info.plist
Expand Up @@ -24,6 +24,8 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
16 changes: 16 additions & 0 deletions SYPaginator.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
B275DFEF1509783500D6E7C1 /* SYPageView.h in Headers */ = {isa = PBXBuildFile; fileRef = B275DFED1509783500D6E7C1 /* SYPageView.h */; };
B275DFF01509783500D6E7C1 /* SYPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = B275DFEE1509783500D6E7C1 /* SYPageView.m */; };
B275DFF31509788C00D6E7C1 /* SYPaginatorScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = B275DFF11509788C00D6E7C1 /* SYPaginatorScrollView.h */; };
B275DFF41509788C00D6E7C1 /* SYPaginatorScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = B275DFF21509788C00D6E7C1 /* SYPaginatorScrollView.m */; };
B2C4DF571509621B00ABF21F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2C4DF561509621B00ABF21F /* Foundation.framework */; };
B2C4DFAE1509631500ABF21F /* SYPaginatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C4DFA91509631500ABF21F /* SYPaginatorView.h */; };
B2C4DFAF1509631500ABF21F /* SYPaginatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C4DFAA1509631500ABF21F /* SYPaginatorView.m */; };
Expand All @@ -16,6 +20,10 @@

/* Begin PBXFileReference section */
B275DFCB150964F100D6E7C1 /* SYPaginator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SYPaginator.h; sourceTree = "<group>"; };
B275DFED1509783500D6E7C1 /* SYPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SYPageView.h; sourceTree = "<group>"; };
B275DFEE1509783500D6E7C1 /* SYPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SYPageView.m; sourceTree = "<group>"; };
B275DFF11509788C00D6E7C1 /* SYPaginatorScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SYPaginatorScrollView.h; sourceTree = "<group>"; };
B275DFF21509788C00D6E7C1 /* SYPaginatorScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SYPaginatorScrollView.m; sourceTree = "<group>"; };
B2C4DF531509621B00ABF21F /* libSYPaginator.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSYPaginator.a; sourceTree = BUILT_PRODUCTS_DIR; };
B2C4DF561509621B00ABF21F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
B2C4DFA91509631500ABF21F /* SYPaginatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SYPaginatorView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -69,6 +77,10 @@
B2C4DFAA1509631500ABF21F /* SYPaginatorView.m */,
B2C4DFAB1509631500ABF21F /* SYPaginatorViewController.h */,
B2C4DFAC1509631500ABF21F /* SYPaginatorViewController.m */,
B275DFED1509783500D6E7C1 /* SYPageView.h */,
B275DFEE1509783500D6E7C1 /* SYPageView.m */,
B275DFF11509788C00D6E7C1 /* SYPaginatorScrollView.h */,
B275DFF21509788C00D6E7C1 /* SYPaginatorScrollView.m */,
);
path = SYPaginator;
sourceTree = "<group>";
Expand All @@ -82,6 +94,8 @@
files = (
B2C4DFAE1509631500ABF21F /* SYPaginatorView.h in Headers */,
B2C4DFB01509631500ABF21F /* SYPaginatorViewController.h in Headers */,
B275DFEF1509783500D6E7C1 /* SYPageView.h in Headers */,
B275DFF31509788C00D6E7C1 /* SYPaginatorScrollView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -138,6 +152,8 @@
files = (
B2C4DFAF1509631500ABF21F /* SYPaginatorView.m in Sources */,
B2C4DFB11509631500ABF21F /* SYPaginatorViewController.m in Sources */,
B275DFF01509783500D6E7C1 /* SYPageView.m in Sources */,
B275DFF41509788C00D6E7C1 /* SYPaginatorScrollView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

18 changes: 18 additions & 0 deletions SYPaginator/SYPageView.h
@@ -0,0 +1,18 @@
//
// SYPageView.h
// SYPaginator
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SYPageView : UIView

@property (nonatomic, strong, readonly) NSString *reuseIdentifier;

- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier;
- (void)prepareForReuse;

@end
32 changes: 32 additions & 0 deletions SYPaginator/SYPageView.m
@@ -0,0 +1,32 @@
//
// SYPageView.m
// SYPaginator
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

#import "SYPageView.h"

@interface SYPageView ()
@property (nonatomic, strong, readwrite) NSString *reuseIdentifier;
@end

@implementation SYPageView

@synthesize reuseIdentifier = _reuseIdentifier;

- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithFrame:CGRectZero])) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.reuseIdentifier = reuseIdentifier;
}
return self;
}


- (void)prepareForReuse {
// Subclasses may override this
}

@end
1 change: 1 addition & 0 deletions SYPaginator/SYPaginator.h
Expand Up @@ -8,3 +8,4 @@

#import <SYPaginator/SYPaginatorView.h>
#import <SYPaginator/SYPaginatorViewController.h>
#import <SYPaginator/SYPageView.h>
15 changes: 15 additions & 0 deletions SYPaginator/SYPaginatorScrollView.h
@@ -0,0 +1,15 @@
//
// SYPaginatorScrollView.h
// SYPaginator
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SYPaginatorScrollView : UIScrollView

@property (nonatomic, unsafe_unretained) id<UIScrollViewDelegate> privateDelegate;

@end
27 changes: 27 additions & 0 deletions SYPaginator/SYPaginatorScrollView.m
@@ -0,0 +1,27 @@
//
// SYPaginatorScrollView.m
// SYPaginator
//
// Created by Sam Soffes on 3/8/12.
// Copyright (c) 2012 Synthetic. All rights reserved.
//

#import "SYPaginatorScrollView.h"

@implementation SYPaginatorScrollView

- (void)setDelegate:(id<UIScrollViewDelegate>)delegate {
return;
}


- (id<UIScrollViewDelegate>)privateDelegate {
return [self delegate];
}


- (void)setPrivateDelegate:(id<UIScrollViewDelegate>)privateDelegate {
[super setDelegate:privateDelegate];
}

@end

0 comments on commit 86890e5

Please sign in to comment.