Skip to content

Commit

Permalink
iPad support
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonjs committed Dec 20, 2011
1 parent ab53861 commit f441071
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 108 deletions.
16 changes: 8 additions & 8 deletions 5by5Browser.xcodeproj/project.pbxproj
Expand Up @@ -9,8 +9,8 @@
/* Begin PBXBuildFile section */
7B043E87149D6984004B52E8 /* back.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E83149D6984004B52E8 /* back.png */; };
7B043E88149D6984004B52E8 /* back@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E84149D6984004B52E8 /* back@2x.png */; };
7B043E89149D6984004B52E8 /* forw.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E85149D6984004B52E8 /* forw.png */; };
7B043E8A149D6984004B52E8 /* forw@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E86149D6984004B52E8 /* forw@2x.png */; };
7B043E89149D6984004B52E8 /* forward.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E85149D6984004B52E8 /* forward.png */; };
7B043E8A149D6984004B52E8 /* forward@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E86149D6984004B52E8 /* forward@2x.png */; };
7B043E8E149D6FA0004B52E8 /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E8C149D6FA0004B52E8 /* icon.png */; };
7B043E8F149D6FA0004B52E8 /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B043E8D149D6FA0004B52E8 /* icon@2x.png */; };
7B1A6ECF149D140600FC5105 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B1A6ECE149D140600FC5105 /* UIKit.framework */; };
Expand Down Expand Up @@ -62,8 +62,8 @@
/* Begin PBXFileReference section */
7B043E83149D6984004B52E8 /* back.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = back.png; sourceTree = "<group>"; };
7B043E84149D6984004B52E8 /* back@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "back@2x.png"; sourceTree = "<group>"; };
7B043E85149D6984004B52E8 /* forw.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = forw.png; sourceTree = "<group>"; };
7B043E86149D6984004B52E8 /* forw@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "forw@2x.png"; sourceTree = "<group>"; };
7B043E85149D6984004B52E8 /* forward.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = forward.png; sourceTree = "<group>"; };
7B043E86149D6984004B52E8 /* forward@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "forward@2x.png"; sourceTree = "<group>"; };
7B043E8C149D6FA0004B52E8 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
7B043E8D149D6FA0004B52E8 /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon@2x.png"; sourceTree = "<group>"; };
7B1A6ECA149D140600FC5105 /* 5by5Browser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 5by5Browser.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -204,8 +204,8 @@
7B043E8D149D6FA0004B52E8 /* icon@2x.png */,
7B043E83149D6984004B52E8 /* back.png */,
7B043E84149D6984004B52E8 /* back@2x.png */,
7B043E85149D6984004B52E8 /* forw.png */,
7B043E86149D6984004B52E8 /* forw@2x.png */,
7B043E85149D6984004B52E8 /* forward.png */,
7B043E86149D6984004B52E8 /* forward@2x.png */,
7B1A6ED6149D140600FC5105 /* 5by5Browser-Info.plist */,
7B1A6ED7149D140600FC5105 /* InfoPlist.strings */,
7B1A6EDA149D140600FC5105 /* main.m */,
Expand Down Expand Up @@ -347,8 +347,8 @@
7B868952149D5C6F00F3A2C6 /* ShowViewController_iPhone.xib in Resources */,
7B043E87149D6984004B52E8 /* back.png in Resources */,
7B043E88149D6984004B52E8 /* back@2x.png in Resources */,
7B043E89149D6984004B52E8 /* forw.png in Resources */,
7B043E8A149D6984004B52E8 /* forw@2x.png in Resources */,
7B043E89149D6984004B52E8 /* forward.png in Resources */,
7B043E8A149D6984004B52E8 /* forward@2x.png in Resources */,
7B043E8E149D6FA0004B52E8 /* icon.png in Resources */,
7B043E8F149D6FA0004B52E8 /* icon@2x.png in Resources */,
);
Expand Down
Binary file not shown.
20 changes: 16 additions & 4 deletions 5by5Browser/SSAppDelegate.m
Expand Up @@ -9,6 +9,7 @@
#import "SSAppDelegate.h"
#import "SSMasterViewController.h"
#import "SSDetailViewController.h"
#import "ShowViewController.h"
#import "FiveByFive.h"
#import "Show.h"

Expand All @@ -33,25 +34,36 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
SSMasterViewController *masterViewController = [[SSMasterViewController alloc] initWithNibName:@"SSMasterViewController_iPhone" bundle:nil];
ShowViewController *showViewController = [[ShowViewController alloc] initWithNibName: @"ShowViewController_iPhone" bundle: nil];
SSDetailViewController *detailViewController = [[SSDetailViewController alloc] initWithNibName:@"SSDetailViewController_iPhone" bundle:nil];

masterViewController.fiveByFive = fiveByFive;
masterViewController.showViewController = showViewController;
showViewController.detailViewController = detailViewController;

self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
[self.navigationController.navigationBar setTintColor: [UIColor colorWithWhite: 0.3 alpha: 1.0]];
self.window.rootViewController = self.navigationController;
} else {
SSMasterViewController *masterViewController = [[SSMasterViewController alloc] initWithNibName:@"SSMasterViewController_iPad" bundle:nil];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
[masterNavigationController.navigationBar setTintColor: [UIColor colorWithWhite: 0.3 alpha: 1.0]];


ShowViewController *showViewController = [[ShowViewController alloc] initWithNibName: @"ShowViewController_iPad" bundle: nil];

SSDetailViewController *detailViewController = [[SSDetailViewController alloc] initWithNibName:@"SSDetailViewController_iPad" bundle:nil];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
[detailNavigationController.navigationBar setTintColor: [UIColor colorWithWhite: 0.3 alpha: 1.0]];

masterViewController.fiveByFive = fiveByFive;

masterViewController.showViewController = showViewController;
showViewController.detailViewController = detailViewController;
[detailNavigationController setNavigationBarHidden: YES];

self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];

self.window.rootViewController = self.splitViewController;
}
[self.window makeKeyAndVisible];
Expand Down
1 change: 0 additions & 1 deletion 5by5Browser/SSDetailViewController.h
Expand Up @@ -12,7 +12,6 @@
@interface SSDetailViewController : UIViewController <UISplitViewControllerDelegate, UIWebViewDelegate>

@property (strong, nonatomic) Episode *episode;
@property (strong, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) IBOutlet UIToolbar *toolbar;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *backButton;
Expand Down
51 changes: 39 additions & 12 deletions 5by5Browser/SSDetailViewController.m
Expand Up @@ -12,14 +12,16 @@
#import "UIAlertView+marshmallows.h"

@interface SSDetailViewController ()
{
UIBarButtonItem *_showsButton;
}
@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
- (void) configureView;
@end

@implementation SSDetailViewController

@synthesize episode = _episode;
@synthesize detailDescriptionLabel = _detailDescriptionLabel;
@synthesize webView = _webView;
@synthesize toolbar = _toolbar;
@synthesize backButton = _backButton;
Expand Down Expand Up @@ -48,15 +50,24 @@ - (void)configureView
{
if (self.episode) {
self.title = self.episode.name;
self.detailDescriptionLabel.text = self.episode.name;
[self goHome: nil];
}
else {
self.title = @"5by5";
}
[self goHome: nil];
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];

if (_showsButton) {
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items insertObject: _showsButton atIndex: 0];
[self.toolbar setItems: items animated: YES];
_showsButton = nil;
}
}

- (void)viewDidUnload
Expand All @@ -68,8 +79,6 @@ - (void)viewDidUnload
[self setToolbar:nil];
[self setLoadingView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
self.detailDescriptionLabel = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down Expand Up @@ -99,7 +108,12 @@ - (void) webViewDidFinishLoad: (UIWebView *)webView

- (IBAction) goHome: (id)sender
{
[self.webView loadRequest: [NSURLRequest requestWithURL: self.episode.url]];
if (self.episode) {
[self.webView loadRequest: [NSURLRequest requestWithURL: self.episode.url]];
}
else {
[self.webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: @"http://5by5.tv"]]];
}
}

- (IBAction) sendToInstapaper: (id)sender
Expand Down Expand Up @@ -129,17 +143,30 @@ - (IBAction) sendToInstapaper: (id)sender

#pragma mark - Split view

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
- (void) splitViewController: (UISplitViewController *)splitController
willHideViewController: (UIViewController *)viewController
withBarButtonItem: (UIBarButtonItem *)barButtonItem
forPopoverController: (UIPopoverController *)popoverController
{
barButtonItem.title = @"Shows";
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
if (self.toolbar) {
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items insertObject: barButtonItem atIndex: 0];
[self.toolbar setItems: items animated: YES];
}
else {
_showsButton = barButtonItem;
}
self.masterPopoverController = popoverController;
}

- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
- (void) splitViewController: (UISplitViewController *)splitController
willShowViewController: (UIViewController *)viewController
invalidatingBarButtonItem: (UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items removeObject: barButtonItem];
[self.toolbar setItems: items animated: YES];
self.masterPopoverController = nil;
}

Expand Down
2 changes: 2 additions & 0 deletions 5by5Browser/SSMasterViewController.h
Expand Up @@ -7,11 +7,13 @@
//

#import <UIKit/UIKit.h>
#import "ShowViewController.h"
#import "FiveByFive.h"
#import "Show.h"

@interface SSMasterViewController : UITableViewController <ShowDelegate>

@property (nonatomic, retain) FiveByFive *fiveByFive;
@property (nonatomic, retain) ShowViewController *showViewController;

@end
41 changes: 6 additions & 35 deletions 5by5Browser/SSMasterViewController.m
Expand Up @@ -7,50 +7,33 @@
//

#import "SSMasterViewController.h"
#import "ShowViewController.h"
#import "Show.h"

@implementation SSMasterViewController

@synthesize showViewController = _showViewController;
@synthesize fiveByFive = _fiveByFive;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"5by5 Shows";
self.title = @"Shows";
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (void) viewWillAppear: (BOOL)animated
{
[super viewWillAppear: animated];

for (int i = 0; i < [self tableView: self.tableView numberOfRowsInSection: 0]; ++i) {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath: [NSIndexPath indexPathForRow: i inSection: 0]];
cell.accessoryView = nil;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}

Expand Down Expand Up @@ -91,12 +74,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

Show *show = [self.fiveByFive.shows objectAtIndex: indexPath.row];
show.delegate = self;
Expand All @@ -114,15 +92,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (void) gotEpisodesForShow: (Show *)show
{
ShowViewController *vc;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
vc = [[ShowViewController alloc] initWithNibName: @"ShowViewController_iPhone" bundle: nil];
}
else {
vc = [[ShowViewController alloc] initWithNibName: @"ShowViewController_iPad" bundle: nil];
}
vc.show = show;
[self.navigationController pushViewController: vc animated:YES];
self.showViewController.show = show;
[self.navigationController pushViewController: self.showViewController animated: YES];
}

@end
7 changes: 3 additions & 4 deletions 5by5Browser/Show.m
Expand Up @@ -68,18 +68,17 @@ - (NSURL *) feedURL

- (void) feedParserDidStart: (MWFeedParser *)parser
{
NSLog(@"feed parser started");
// NSLog(@"feed parser started");
}

- (void) feedParser: (MWFeedParser *)parser didParseFeedInfo: (MWFeedInfo *)info
{
NSLog(@"feed info: %@", info);
// NSLog(@"feed info: %@", info);
}

- (void) feedParser: (MWFeedParser *)parser didParseFeedItem: (MWFeedItem *)item
{
NSLog(@"feed item: %@", item);
NSLog(@"show name: %@", self.name);
// NSLog(@"feed item: %@", item);
[self addEpisode: [Episode episodeWithShow: self name: item.title number: @"<n>" url: [NSURL URLWithString: item.link]]];
}

Expand Down
31 changes: 16 additions & 15 deletions 5by5Browser/ShowViewController.m
Expand Up @@ -23,34 +23,40 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if (self.show) {
[self configureView];
}
}

- (void)viewDidUnload
- (void) configureView
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.title = self.show.name;
[self.tableView reloadData];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}

- (void) setShow: (Show *)show
{
_show = show;
self.title = self.show.name;
[self.tableView reloadData];
[self configureView];
}

#pragma mark - Table View
Expand Down Expand Up @@ -87,14 +93,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Episode *episode = [self.show.episodes objectAtIndex: indexPath.row];
self.detailViewController.episode = episode;
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;
}
}

Expand Down

0 comments on commit f441071

Please sign in to comment.