mirror of
https://github.com/samsonjs/5by5Browser.git
synced 2026-04-13 12:15:47 +00:00
101 lines
2.8 KiB
Objective-C
101 lines
2.8 KiB
Objective-C
//
|
|
// ShowViewController.m
|
|
// 5by5Browser
|
|
//
|
|
// Created by Sami Samhuri on 11-12-17.
|
|
// Copyright (c) 2011 Guru Logic. All rights reserved.
|
|
//
|
|
|
|
#import "ShowViewController.h"
|
|
#import "SSDetailViewController.h"
|
|
#import "Episode.h"
|
|
|
|
@interface ShowViewController ()
|
|
|
|
@end
|
|
|
|
@implementation ShowViewController
|
|
|
|
@synthesize detailViewController = _detailViewController;
|
|
@synthesize show = _show;
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
{
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
if (self) {
|
|
// Custom initialization
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view from its nib.
|
|
}
|
|
|
|
- (void)viewDidUnload
|
|
{
|
|
[super viewDidUnload];
|
|
// Release any retained subviews of the main view.
|
|
// e.g. self.myOutlet = nil;
|
|
}
|
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
|
{
|
|
return (interfaceOrientation == UIInterfaceOrientationPortrait);
|
|
}
|
|
|
|
- (void) setShow: (Show *)show
|
|
{
|
|
_show = show;
|
|
self.title = self.show.name;
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
#pragma mark - Table View
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
return self.show.episodes.count;
|
|
}
|
|
|
|
// Customize the appearance of table view cells.
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
static NSString *CellIdentifier = @"Cell";
|
|
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
if (cell == nil) {
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
|
|
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
|
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
}
|
|
}
|
|
|
|
|
|
Episode *episode = [self.show.episodes objectAtIndex: indexPath.row];
|
|
cell.textLabel.text = episode.name;
|
|
return cell;
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
Episode *episode = [self.show.episodes objectAtIndex: indexPath.row];
|
|
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
|
if (!self.detailViewController) {
|
|
self.detailViewController = [[SSDetailViewController alloc] initWithNibName: @"SSDetailViewController_iPhone" bundle: nil];
|
|
}
|
|
self.detailViewController.episode = episode;
|
|
[self.navigationController pushViewController: self.detailViewController animated:YES];
|
|
} else {
|
|
self.detailViewController.episode = episode;
|
|
}
|
|
}
|
|
|
|
@end
|