-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUITableView+GangnamStyle.m
175 lines (142 loc) · 5.89 KB
/
UITableView+GangnamStyle.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//
// UITableView+GangnamStyle.m
// Gangnam Style
//
// Created by Matthew Robinson on 20/10/12.
// Copyright (c) 2012 Matthew Robinson. All rights reserved.
//
#import "UITableView+GangnamStyle.h"
#import <objc/runtime.h>
@interface PSYGangnam : NSObject <UITableViewDataSource>
+ (id)sharedGangnam;
@property (strong,readonly,nonatomic) NSArray *lyrics;
@end
@implementation UITableView (GangnamStyle)
+ (void)load {
method_exchangeImplementations(
class_getInstanceMethod(self, @selector(initWithFrame:style:)),
class_getInstanceMethod(self, @selector(initWithFrame_PSY:style:))
);
}
- (id)initWithFrame_PSY:(CGRect)frame style:(UITableViewStyle)style {
// Call the original initWithFrame:style: which is now
// called PSY_initWithFrame:style: This is NOT recursive!
// If the style is Gangnam actually use plain
self = [self initWithFrame_PSY:frame
style:style == UITableViewStyleGangnam ? UITableViewStylePlain : style];
// Set the data source if Gangnam style
if (self && style == UITableViewStyleGangnam) {
[self setDataSource:[PSYGangnam sharedGangnam]];
}
return self;
}
@end
@implementation PSYGangnam
+ (id)sharedGangnam {
static PSYGangnam *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[PSYGangnam alloc] init];
});
return sharedInstance;
}
- (id)init {
self = [super init];
if (self) {
_lyrics = @[@"Oppan Gangnam Style",
@"Gangnam Style",
@"",
@"Na je nun ta sa ro un in gan jo gin yo ja",
@"Ko pi han ja ne yo yu rul a neun pum gyo gi nun yo ja",
@"Ba mi o myon shim ja ngi tu go wo ji nun yo ja",
@"Gu ron ban jon i nun yo ja",
@"",
@"Na nun sa na ye",
@"Na je nun no man kum ta sa ro un gu ron sa na ye",
@"Ko pi shik gi do jo ne one shot te ri nun sa na ye",
@"Ba mi o myon shim ja ngi to jyo bo ri nun sa na ye",
@"Gu ron sa na ye",
@"",
@"A rum de wo sa rang su ro wo",
@"Gu re no hey gu re ba ro no hey",
@"A reum de wo sa rang su ro wo",
@"Gu re no hey gu re ba ro no hey",
@"Ji gum bu to gal de ka ji ga bol ka",
@"",
@"Oppan Gangnam Style",
@"Gangnam Style",
@"Op op op op oppan Gangnam Style",
@"Gangnam Style",
@"Op op op op oppan Gangnam Style",
@"",
@"Eh~ Sexy lady",
@"Op op op op oppan Gangnam Style",
@"Eh~ Sexy lady",
@"Op op op op",
@"Eh eh eh eh eh eh",
@"",
@"Jong su ke bo wi ji man nol ten no nun yo ja",
@"I te da shi pu myon mu ko ton mo ri pu nun yo ja",
@"Ga ryot ji man wen man han no chul boda ya han yo ja",
@"Gu ron gam gak jo gin yo ja",
@"",
@"Na nun sa na ye",
@"Jom ja na bo wi ji man nol ten no nun sa na ye",
@"Te ga dwe myon wan jon mi cho bo ri nun sa na ye",
@"Gun yuk bo da sa sa ngi ul tung bul tu ngan sa na ye",
@"Gu ron sa na ye",
@"",
@"A rum de wo sa rang su ro wo",
@"Gu re no hey gu re ba ro no hey",
@"A reum de wo sa rang su ro wo",
@"Gu re no hey gu re ba ro no hey",
@"Ji gum bu to gal de ka ji ga bol ka",
@"",
@"Oppan Gangnam Style",
@"Gangnam Style",
@"Op op op op oppan Gangnam Style",
@"Gangnam Style",
@"Op op op op oppan Gangnam Style",
@"",
@"Eh~ Sexy lady",
@"Op op op op oppan Gangnam Style",
@"Eh~ Sexy lady",
@"Op op op op",
@"Eh eh eh eh eh eh",
@"",
@"Twi nun nom gu wi ye na nun nom",
@"Baby baby na nun mol jom a nun nom",
@"Twi nun nom gu wi ye na nun nom",
@"Baby baby na nun mol jom a nun nom",
@"You know what I'm saying",
@"",
@"Oppan Gangnam Style",
@"Eh eh eh eh eh eh",
@"",
@"Eh~ Sexy lady",
@"Op op op op oppan Gangnam Style",
@"Eh~ Sexy lady",
@"Op op op op",
@"Eh eh eh eh eh eh",
@"",
@"Oppan Gangnam Style",
@"",
@"© Sony/ATV Music Publishing LLC"];
}
return self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_lyrics count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *PSYGangnamCellIdentifier = @"PSYGangnamCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PSYGangnamCellIdentifier];
if (nil == cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:PSYGangnamCellIdentifier];
[[cell textLabel] setFont:[UIFont fontWithName:@"Helvetica-Bold" size:11.0]];
}
[[cell textLabel] setText:[_lyrics objectAtIndex:[indexPath row]]];
return cell;
}
@end