@@ -38,7 +38,7 @@ - (void) selectedRow:(NSUInteger) row;
38
38
39
39
@interface CCTableViewCellHolder : NSObject
40
40
41
- @property (nonatomic ,strong ) CCTableViewCell* cell;
41
+ @property (nonatomic ,strong ) id <CCTableViewCellProtocol> cell;
42
42
43
43
@end
44
44
@@ -67,12 +67,13 @@ - (void) setPosition:(CGPoint)position
67
67
68
68
@interface CCTableViewCell (Helper)
69
69
70
- @property (nonatomic ,assign ) NSUInteger index;
71
-
72
70
@end
73
71
72
+
74
73
@implementation CCTableViewCell
75
74
75
+ @synthesize index;
76
+
76
77
- (id ) init
77
78
{
78
79
self = [super init ];
@@ -94,16 +95,6 @@ - (void) pressedCell:(id)sender
94
95
[(CCTableView*)(self .parent.parent) selectedRow: self .index];
95
96
}
96
97
97
- - (void ) setIndex : (NSUInteger )index
98
- {
99
- _index = index;
100
- }
101
-
102
- - (NSUInteger ) index
103
- {
104
- return _index;
105
- }
106
-
107
98
@end
108
99
109
100
@@ -244,7 +235,7 @@ - (void) showRowsForRange:(NSRange)range
244
235
CCTableViewCellHolder* holder = [_rows objectAtIndex: oldIdx];
245
236
if (holder)
246
237
{
247
- [self .contentNode removeChild: holder.cell cleanup: YES ];
238
+ [self .contentNode removeChild: (CCNode*) holder.cell cleanup: YES ];
248
239
holder.cell = NULL ;
249
240
}
250
241
}
@@ -255,18 +246,23 @@ - (void) showRowsForRange:(NSRange)range
255
246
if (!NSLocationInRange (newIdx, _currentlyVisibleRange))
256
247
{
257
248
CCTableViewCellHolder* holder = [_rows objectAtIndex: newIdx];
249
+ CCNode* node;
258
250
if (!holder.cell )
259
251
{
260
252
holder.cell = [_dataSource tableView: self nodeForRowAtIndex: newIdx];
261
253
holder.cell .index = newIdx;
262
- holder.cell .position = CGPointMake (0 , [self locationForCellWithIndex: newIdx]);
263
- holder.cell .positionType = CCPositionTypeMake (CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
264
- holder.cell .anchorPoint = CGPointMake (0 , 1 );
254
+
255
+ node = (CCNode*)holder.cell ;
256
+ node.position = CGPointMake (0 , [self locationForCellWithIndex: newIdx]);
257
+ node.positionType = CCPositionTypeMake (CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
258
+ node.anchorPoint = CGPointMake (0 , 1 );
259
+ } else {
260
+ node = (CCNode*)holder.cell ;
265
261
}
266
262
267
263
if (holder.cell )
268
264
{
269
- [self .contentNode addChild: holder.cell ];
265
+ [self .contentNode addChild: node ];
270
266
}
271
267
}
272
268
}
@@ -395,7 +391,7 @@ - (void) setTarget:(id)target selector:(SEL)selector
395
391
}];
396
392
}
397
393
398
- - (void ) selectedRow : (NSUInteger ) row
394
+ - (void ) selectedRow : (NSUInteger )row
399
395
{
400
396
self.selectedRow = row;
401
397
[self triggerAction ];
0 commit comments