This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TTCatalog] Add SplitCatalogController.
- Loading branch information
Showing
4 changed files
with
270 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
@interface SplitCatalogController : TTSplitViewController { | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#import "SplitCatalogController.h" | ||
|
||
#import "CatalogController.h" | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
@interface SplitCatalogController() | ||
|
||
- (void)setupURLRouting; | ||
|
||
@end | ||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
@implementation SplitCatalogController | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | ||
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { | ||
[self setupURLRouting]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
|
||
[self.leftNavigator openURLs:@"tt://catalog", nil]; | ||
[self.rightNavigator openURLs:@"http://three20.info/", nil]; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (id)willOpenUrlPath:(NSURL*)url { | ||
[self.rightNavigator openURLAction:[TTURLAction actionWithURLPath:[url absoluteString]]]; | ||
|
||
[self.popoverSplitController dismissPopoverAnimated:YES]; | ||
|
||
// We need to do this because the right navigator clobbered the right navigation controller | ||
// and our button along with it. | ||
[self updateSplitViewButton]; | ||
|
||
// Don't create a view controller here; we're forwarding the URL routing. | ||
return nil; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (void)routeLeftNavigator { | ||
TTURLMap* map = self.leftNavigator.URLMap; | ||
|
||
// Forward all unhandled URL actions to the right navigator. | ||
[map from: @"*" | ||
toObject: self | ||
selector: @selector(willOpenUrlPath:)]; | ||
|
||
[map from: @"tt://catalog" | ||
toViewController: [CatalogController class]]; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (void)routeRightNavigator { | ||
TTURLMap* map = self.rightNavigator.URLMap; | ||
|
||
|
||
[map from: @"*" | ||
toViewController: [TTWebController class]]; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
- (void)setupURLRouting { | ||
[self routeLeftNavigator]; | ||
[self routeRightNavigator]; | ||
} | ||
|
||
|
||
@end | ||
|
Oops, something went wrong.