-
Notifications
You must be signed in to change notification settings - Fork 0
/
TraffleViewController.m
96 lines (72 loc) · 2.79 KB
/
TraffleViewController.m
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
90
91
92
93
94
95
96
//
// TraffleViewController.m
// PopTestAnimation
//
// Created by Nikolay Derkach on 29/05/14.
// Copyright (c) 2014 Nikolay Derkach. All rights reserved.
//
#import "TraffleViewController.h"
#import <POP.h>
static float delay = 0.0f;
@interface TraffleViewController ()
@end
@implementation TraffleViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cellForRowAtIndexPath: %ld", (long)[indexPath row]);
NSString *CellIdentifier = [NSString stringWithFormat:@"%ld", (long)[indexPath row]];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// Configure the cell
cell.textLabel.text = [NSString stringWithFormat:@"test %f", delay];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
CGFloat toValue = CGRectGetMidX(self.view.bounds);
POPSpringAnimation *onscreenAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
onscreenAnimation.fromValue = @(-toValue);
onscreenAnimation.toValue = @(toValue);
onscreenAnimation.springBounciness = 5.0f;
onscreenAnimation.beginTime = (CACurrentMediaTime() + delay);
onscreenAnimation.delegate = self;
onscreenAnimation.name = [NSString stringWithFormat:@"%ld", (long)[indexPath row]];
delay+=0.7f;
cell.hidden = YES;
[cell.layer pop_addAnimation:onscreenAnimation forKey:onscreenAnimation.name];
}
return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Displaying row: %ld", (long)[indexPath row]);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSLog(@"numberOfSectionsInTableView");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"numberOfRowsInSection");
return 3;
}
-(void)pop_animationDidStart:(POPAnimation *)anim
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath: [NSIndexPath indexPathForRow:[anim.name intValue] inSection:0]];
cell.hidden = NO;
NSLog(@"cell: %@ %d %d", cell.textLabel.text, [anim.name intValue], cell.hidden);
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100.0f;
}
@end