-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannelViewController.m
70 lines (55 loc) · 2.19 KB
/
ChannelViewController.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
//
// ChannelViewController.m
// Nerdfeed
//
// Created by THOMAS PENG on 6/20/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "ChannelViewController.h"
#import "RSSChannel.h"
@implementation ChannelViewController
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"UITableViewCell"];
if ([indexPath row] == 0) {
// Put the titel of the channel in row 0
[[cell textLabel] setText:@"Title"];
[[cell detailTextLabel] setText:[channel title]];
} else {
// Put the description of the channel in row 1
[[cell textLabel] setText:@"Info"];
[[cell detailTextLabel] setText:[channel infoString]];
}
return cell;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
return YES;
return io == UIInterfaceOrientationPortrait;
}
- (void)listViewController:(ListViewController *)lvc handleObject:(id)object
{
// Make sure the ListViewController gave us the right object
if (![object isKindOfClass:[RSSChannel class]])
return;
channel = object;
[[self tableView] reloadData];
}
- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
{
[barButtonItem setTitle:@"List"];
[[self navigationItem] setLeftBarButtonItem:barButtonItem];
}
- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
if (barButtonItem == [[self navigationItem] leftBarButtonItem])
[[self navigationItem] setLeftBarButtonItem:nil];
}
@end