-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJOGridView.h
83 lines (62 loc) · 2.18 KB
/
JOGridView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// JOGridView.h
// gridview
//
// Created by Jeremy Foo on 9/7/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JOGridViewCell.h"
@class JOGridView;
/// Delegate
@protocol JOGridViewDelegate <NSObject, UIScrollViewDelegate>
@optional
-(void)willDisplayCell:(JOGridViewCell *)cell forGridView:(JOGridView *)gridView atIndexPath:(NSIndexPath *)indexPath;
-(CGFloat)gridView:(JOGridView *)gridview heightForRow:(NSUInteger)row;
@end
/// Data Sources are required
@protocol JOGridViewDataSource <NSObject>
@required
-(NSUInteger)rowsForGridView:(JOGridView *)gridView;
-(NSUInteger)columnsForGridView:(JOGridView *)gridView;
-(JOGridViewCell *)cellForGridView:(JOGridView *)gridView atIndexPath:(NSIndexPath *)indexPath;
@end
@interface JOGridView : UIScrollView {
// debug
BOOL debug;
UILabel* debugInfoLabel;
// cached data
NSUInteger __rows;
NSUInteger __columns;
NSUInteger __firstWarpedInRow;
CGFloat __firstWarpedInRowHeight;
NSUInteger __lastWarpedInRow;
CGFloat __lastWarpedInRowHeight;
// ivar properties
CGFloat __previousOffset;
BOOL __dataSourceDirty;
NSMutableArray* __visibleRows;
NSMutableDictionary* __reusableViews;
id <JOGridViewDelegate> gridViewDelegate;
id <JOGridViewDataSource> gridViewDataSource;
}
@property (nonatomic, assign) id<JOGridViewDataSource> datasource;
@property (nonatomic, assign) id <JOGridViewDelegate> delegate;
@property (readwrite) BOOL debug;
/// cell accessors
@property (readonly) NSArray *visibleRows;
-(NSArray *)indexPathsForVisibleCells;
-(NSIndexPath *)indexPathForVisibleCell:(JOGridViewCell *)cell;
-(JOGridViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;
/// scrolling
-(void)scrollToRow:(NSUInteger)row animated:(BOOL)animated;
-(void)scrollToIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
/// gridview properties
@property (readonly) NSUInteger numberOfRows;
@property (readonly) NSUInteger numberOfColumns;
/// reload methods
-(void)reloadData;
-(void)reloadRow:(NSUInteger)row;
-(void)reloadCellAtIndexPath:(NSIndexPath *)indexPath;
-(JOGridViewCell *)dequeueReusableCellWithIdenitifer:(NSString *)identifier;
@end