-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelsViewController.m
More file actions
104 lines (84 loc) · 2.6 KB
/
ChannelsViewController.m
File metadata and controls
104 lines (84 loc) · 2.6 KB
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
//
// ChannelsViewController.m
// HotNews
//
// Created by gtcc on 9/15/14.
// Copyright (c) 2014 xc. All rights reserved.
//
#import "ChannelsViewController.h"
#import "ChannelAddViewController.h"
@implementation ChannelsViewController
@synthesize sectionData = _sectionData;
-(NSArray*)allChannels
{
return [self.sectionData allKeys];
}
-(NSDictionary*)sectionData
{
if(_sectionData == nil)
{
//_sectionData = [DataLayer GetAllNews:@"0"];
NSMutableArray* a1 = [NSMutableArray new];
NSMutableArray* a2 = [NSMutableArray new];
NSMutableArray* a3 = [NSMutableArray new];
[a1 addObject:@"CocoaChina"];
[a1 addObject:@"IT之家"];
[a1 addObject:@"cnBeta"];
[a2 addObject:@"娱乐八卦"];
[a2 addObject:@"豆瓣影评"];
[a2 addObject:@"八卦娱"];
[a3 addObject:@"NBA"];
[a3 addObject:@"CBA"];
[a3 addObject:@"英超"];
NSMutableDictionary* temp = [NSMutableDictionary new];
[temp setObject:[a1 copy] forKey:@"科技"];
[temp setObject:[a2 copy] forKey:@"娱乐"];
[temp setObject:[a3 copy] forKey:@"体育"];
_sectionData = [temp copy];
}
return _sectionData;
}
-(IBAction) doneTapped:(id) sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ToSingleChannel"]) {
NSIndexPath* indexPath = [self.tableView indexPathForSelectedRow];
ChannelAddViewController* controller = segue.destinationViewController;
controller.allSites = [self.sectionData objectForKey: [self.allChannels objectAtIndex:indexPath.row]];
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
self.sectionData = nil;
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.allChannels count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * tableIdentifier=@"ChannelCell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tableIdentifier];
if(cell==nil)
{
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:tableIdentifier];
}
cell.textLabel.text = [self.allChannels objectAtIndex:indexPath.row];
return cell;
}
@end