forked from ekohe/EKStreamView
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EKStreamView.h
89 lines (60 loc) · 2.47 KB
/
EKStreamView.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
84
85
86
87
88
89
//
// EKStreamView.h
// StreamView
//
// Created by Eli Wang on 1/16/12.
// Copyright (c) 2012 ekohe.com. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol EKResusableCell <NSObject>
@property (nonatomic, retain) NSString *reuseIdentifier;
@end
@interface EKStreamViewCellInfo : NSObject
@property (nonatomic, assign) CGRect frame;
@property (nonatomic, assign) NSUInteger index;
// You SHOULD ONLY access this property when this object is in visibleCellInfo!
@property (nonatomic, weak) UIView<EKResusableCell> *cell;
@end
@class EKStreamView;
@protocol EKStreamViewDelegate <UIScrollViewDelegate>
- (NSInteger)numberOfCellsInStreamView:(EKStreamView *)streamView;
- (NSInteger)numberOfColumnsInStreamView:(EKStreamView *)streamView;
- (UIView<EKResusableCell> *)streamView:(EKStreamView *)streamView cellAtIndex:(NSInteger)index;
- (CGFloat)streamView:(EKStreamView *)streamView heightForCellAtIndex:(NSInteger)index;
@optional
- (UIView *)headerForStreamView:(EKStreamView *)streamView;
- (UIView *)footerForStreamView:(EKStreamView *)streamView;
- (void)streamView:(EKStreamView *)streamView willDisplayCell:(UIView<EKResusableCell> *)cell forIndex:(NSInteger)index;
@optional
@end
@interface EKStreamViewUIScrollViewDelegate : NSObject<UIScrollViewDelegate>
@property (nonatomic, weak) EKStreamView *streamView;
@end
typedef enum {
EKStreamViewScrollPositionNone,
EKStreamViewScrollPositionTop,
EKStreamViewScrollPositionMiddle,
EKStreamViewScrollPositionBottom
} EKStreamViewScrollPosition;
@interface EKStreamView : UIScrollView
{
NSMutableArray
*cellHeightsByIndex, // 1d
*cellHeightsByColumn, // 2d
*rectsForCells, // 2d EKStreamViewCellInfo
*infoForCells; // 1d
NSMutableDictionary *cellCache; // reuseIdentifier => NSMutableArray
NSSet *visibleCellInfo;
CGFloat columnWidth;
EKStreamViewUIScrollViewDelegate *delegateObj;
}
@property (nonatomic, weak) id<EKStreamViewDelegate> delegate;
@property (nonatomic, assign) CGFloat columnPadding;
@property (nonatomic, assign) CGFloat cellPadding;
@property (nonatomic, readonly) CGFloat columnWidth;
@property (nonatomic, readonly) UIView *headerView, *footerView;
@property (nonatomic, readonly) UIView *contentView;
- (id<EKResusableCell>)dequeueReusableCellWithIdentifier:(NSString *)identifier;
- (void)reloadData;
- (void)scrollToCellAtIndex:(NSUInteger)index atScrollPosition:(EKStreamViewScrollPosition)scrollPosition animated:(BOOL)animated;
@end