14
14
15
15
@implementation RootViewController
16
16
@synthesize footerView;
17
+ @synthesize openedIndexPath;
17
18
18
19
- (void )viewDidLoad
19
20
{
@@ -48,7 +49,7 @@ - (void)viewWillAppear:(BOOL)animated
48
49
{
49
50
[super viewWillAppear: animated];
50
51
51
- openedIndexPath_ = nil ; // close all cells
52
+ self. openedIndexPath = nil ; // close all cells
52
53
}
53
54
54
55
- (void )viewDidAppear : (BOOL )animated
@@ -103,12 +104,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
103
104
cell.imageView .image = [UIImage imageNamed: [NSString stringWithFormat: @" image%02d s.jpg" , (r%8 )+1 ]];
104
105
// NSLog(@"%@", [NSString stringWithFormat:@"image%02ds.jpg", (r%8)+1]);
105
106
106
- if ([openedIndexPath_ isEqual: indexPath]) {
107
+ if ([self .openedIndexPath isEqual: indexPath]) {
107
108
[cell setSlideOpened: YES animated: NO ];
108
- [cell setSelected: YES animated: NO ];
109
109
} else {
110
110
[cell setSlideOpened: NO animated: NO ];
111
- [cell setSelected: NO animated: NO ];
112
111
}
113
112
114
113
return cell;
@@ -186,6 +185,7 @@ - (void)viewDidUnload
186
185
- (void )dealloc
187
186
{
188
187
self.footerView = nil ;
188
+ self.openedIndexPath = nil ;
189
189
[super dealloc ];
190
190
}
191
191
@@ -197,24 +197,24 @@ - (void)didSwipeCell:(UISwipeGestureRecognizer*)swipeRecognizer
197
197
NSIndexPath * indexPath = [self .tableView indexPathForRowAtPoint: loc];
198
198
CustomCell* cell = (CustomCell*)[self .tableView cellForRowAtIndexPath: indexPath];
199
199
200
- if ([openedIndexPath_ isEqual: indexPath]) {
200
+ if ([self .openedIndexPath isEqual: indexPath]) {
201
201
if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
202
202
// close cell
203
203
[cell setSlideOpened: NO animated: YES ];
204
- openedIndexPath_ = nil ;
204
+ self. openedIndexPath = nil ;
205
205
}
206
206
} else if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionRight) {
207
- if (openedIndexPath_ ) {
207
+ if (self. openedIndexPath ) {
208
208
// close previous opened cell
209
209
NSArray * visibleIndexPaths = [self .tableView indexPathsForVisibleRows ];
210
- if ([visibleIndexPaths containsObject: openedIndexPath_ ]) {
211
- CustomCell* openedCell = (CustomCell*)[self .tableView cellForRowAtIndexPath: openedIndexPath_ ];
210
+ if ([visibleIndexPaths containsObject: self .openedIndexPath ]) {
211
+ CustomCell* openedCell = (CustomCell*)[self .tableView cellForRowAtIndexPath: self .openedIndexPath ];
212
212
[openedCell setSlideOpened: NO animated: YES ];
213
213
}
214
214
}
215
215
// open new cell
216
216
[cell setSlideOpened: YES animated: YES ];
217
- openedIndexPath_ = indexPath;
217
+ self. openedIndexPath = indexPath;
218
218
}
219
219
220
220
}
0 commit comments