From 687342f7c84d80ac0347d729847a6eb3a2dc27fd Mon Sep 17 00:00:00 2001 From: jverkoey Date: Wed, 17 Nov 2010 13:00:37 -0500 Subject: [PATCH] [TTCatalog] Add SplitCatalogController. --- samples/TTCatalog/Classes/AppDelegate.m | 157 +++++++++++++++--- .../Classes/SplitCatalogController.h | 5 + .../Classes/SplitCatalogController.m | 89 ++++++++++ .../TTCatalog.xcodeproj/project.pbxproj | 40 +++++ 4 files changed, 270 insertions(+), 21 deletions(-) create mode 100644 samples/TTCatalog/Classes/SplitCatalogController.h create mode 100644 samples/TTCatalog/Classes/SplitCatalogController.m diff --git a/samples/TTCatalog/Classes/AppDelegate.m b/samples/TTCatalog/Classes/AppDelegate.m index 0cab04e432..3b66568b63 100644 --- a/samples/TTCatalog/Classes/AppDelegate.m +++ b/samples/TTCatalog/Classes/AppDelegate.m @@ -1,4 +1,5 @@ #import "AppDelegate.h" +#import "SplitCatalogController.h" #import "CatalogController.h" #import "PhotoTest1Controller.h" #import "PhotoTest2Controller.h" @@ -33,27 +34,141 @@ - (void)applicationDidFinishLaunching:(UIApplication*)application { TTURLMap* map = navigator.URLMap; [map from:@"*" toViewController:[TTWebController class]]; - [map from:@"tt://catalog" toViewController:[CatalogController class]]; - [map from:@"tt://photoTest1" toViewController:[PhotoTest1Controller class]]; - [map from:@"tt://photoTest2" toViewController:[PhotoTest2Controller class]]; - [map from:@"tt://imageTest1" toViewController:[ImageTest1Controller class]]; - [map from:@"tt://tableTest" toViewController:[TableTestController class]]; - [map from:@"tt://tableItemTest" toViewController:[TableItemTestController class]]; - [map from:@"tt://tableControlsTest" toViewController:[TableControlsTestController class]]; - [map from:@"tt://styledTextTableTest" toViewController:[StyledTextTableTestController class]]; - [map from:@"tt://tableWithShadow" toViewController:[TableWithShadowController class]]; - [map from:@"tt://tableWithBanner" toViewController:[TableWithBannerController class]]; - [map from:@"tt://composerTest" toViewController:[MessageTestController class]]; - [map from:@"tt://searchTest" toViewController:[SearchTestController class]]; - [map from:@"tt://activityTest" toViewController:[ActivityTestController class]]; - [map from:@"tt://styleTest" toViewController:[StyleTestController class]]; - [map from:@"tt://styledTextTest" toViewController:[StyledTextTestController class]]; - [map from:@"tt://buttonTest" toViewController:[ButtonTestController class]]; - [map from:@"tt://tabBarTest" toViewController:[TabBarTestController class]]; - [map from:@"tt://youTubeTest" toViewController:[YouTubeTestController class]]; - [map from:@"tt://imageTest2" toViewController:[TableImageTestController class]]; - [map from:@"tt://scrollViewTest" toViewController:[ScrollViewTestController class]]; - [map from:@"tt://launcherTest" toViewController:[LauncherViewTestController class]]; + + + if (TTIsPad()) { + [map from: @"tt://catalog" + toSharedViewController: [SplitCatalogController class]]; + + SplitCatalogController* controller = + (SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:@"tt://catalog"]; + TTDASSERT([controller isKindOfClass:[SplitCatalogController class]]); + map = controller.rightNavigator.URLMap; + + } else { + [map from: @"tt://catalog" + toSharedViewController: [CatalogController class]]; + } + + [map from: @"tt://photoTest1" + parent: @"tt://catalog" + toViewController: [PhotoTest1Controller class] + selector: nil + transition: 0]; + [map from: @"tt://photoTest2" + parent: @"tt://catalog" + toViewController: [PhotoTest2Controller class] + selector: nil + transition: 0]; + + [map from: @"tt://imageTest1" + parent: @"tt://catalog" + toViewController: [ImageTest1Controller class] + selector: nil + transition: 0]; + + [map from: @"tt://tableTest" + parent: @"tt://catalog" + toViewController: [TableTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://tableItemTest" + parent: @"tt://catalog" + toViewController: [TableItemTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://tableControlsTest" + parent: @"tt://catalog" + toViewController: [TableControlsTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://styledTextTableTest" + parent: @"tt://catalog" + toViewController: [StyledTextTableTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://tableWithShadow" + parent: @"tt://catalog" + toViewController: [TableWithShadowController class] + selector: nil + transition: 0]; + + [map from: @"tt://tableWithBanner" + parent: @"tt://catalog" + toViewController: [TableWithBannerController class] + selector: nil + transition: 0]; + + [map from: @"tt://composerTest" + parent: @"tt://catalog" + toViewController: [MessageTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://searchTest" + parent: @"tt://catalog" + toViewController: [SearchTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://activityTest" + parent: @"tt://catalog" + toViewController: [ActivityTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://styleTest" + parent: @"tt://catalog" + toViewController: [StyleTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://styledTextTest" + parent: @"tt://catalog" + toViewController: [StyledTextTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://buttonTest" + parent: @"tt://catalog" + toViewController: [ButtonTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://tabBarTest" + parent: @"tt://catalog" + toViewController: [TabBarTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://youTubeTest" + parent: @"tt://catalog" + toViewController: [YouTubeTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://imageTest2" + parent: @"tt://catalog" + toViewController: [TableImageTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://scrollViewTest" + parent: @"tt://catalog" + toViewController: [ScrollViewTestController class] + selector: nil + transition: 0]; + + [map from: @"tt://launcherTest" + parent: @"tt://catalog" + toViewController: [LauncherViewTestController class] + selector: nil + transition: 0]; + if (![navigator restoreViewControllers]) { [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://catalog"]]; diff --git a/samples/TTCatalog/Classes/SplitCatalogController.h b/samples/TTCatalog/Classes/SplitCatalogController.h new file mode 100644 index 0000000000..88ea3dca21 --- /dev/null +++ b/samples/TTCatalog/Classes/SplitCatalogController.h @@ -0,0 +1,5 @@ + +@interface SplitCatalogController : TTSplitViewController { +} + +@end diff --git a/samples/TTCatalog/Classes/SplitCatalogController.m b/samples/TTCatalog/Classes/SplitCatalogController.m new file mode 100644 index 0000000000..35c054702f --- /dev/null +++ b/samples/TTCatalog/Classes/SplitCatalogController.m @@ -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 + diff --git a/samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj b/samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj index 6a9c2ffeda..cf84ae11b7 100755 --- a/samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj +++ b/samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj @@ -58,6 +58,16 @@ 664DFF2A1266315F004C20C2 /* libThree20UINavigator-Xcode3.2.5.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 665E995D12662FE30025FA42 /* libThree20UINavigator-Xcode3.2.5.a */; }; 664DFF2B1266315F004C20C2 /* libThree20UI-Xcode3.2.5.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 665E996A12662FE30025FA42 /* libThree20UI-Xcode3.2.5.a */; }; 664DFF2C1266315F004C20C2 /* libThree20-Xcode3.2.5.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 665E997712662FE30025FA42 /* libThree20-Xcode3.2.5.a */; }; + 666E183012944D23001C1D97 /* SplitCatalogController.m in Sources */ = {isa = PBXBuildFile; fileRef = 666E182F12944D23001C1D97 /* SplitCatalogController.m */; }; + 666E183112944D23001C1D97 /* SplitCatalogController.m in Sources */ = {isa = PBXBuildFile; fileRef = 666E182F12944D23001C1D97 /* SplitCatalogController.m */; }; + 6675F5F412945622008DE0A6 /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F012945622008DE0A6 /* Default-Landscape.png */; }; + 6675F5F512945622008DE0A6 /* Default-Portrait.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F112945622008DE0A6 /* Default-Portrait.png */; }; + 6675F5F612945622008DE0A6 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F212945622008DE0A6 /* Default@2x.png */; }; + 6675F5F712945622008DE0A6 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F312945622008DE0A6 /* Icon@2x.png */; }; + 6675F5F812945622008DE0A6 /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F012945622008DE0A6 /* Default-Landscape.png */; }; + 6675F5F912945622008DE0A6 /* Default-Portrait.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F112945622008DE0A6 /* Default-Portrait.png */; }; + 6675F5FA12945622008DE0A6 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F212945622008DE0A6 /* Default@2x.png */; }; + 6675F5FB12945622008DE0A6 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6675F5F312945622008DE0A6 /* Icon@2x.png */; }; 6E002567116A6D1A00D1F0CB /* TableWithShadowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E002566116A6D1A00D1F0CB /* TableWithShadowController.m */; }; 6E3794F511B9B6DB0011C497 /* libThree20Core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E3794D411B9B6D70011C497 /* libThree20Core.a */; }; 6E3794F611B9B6DC0011C497 /* libThree20Network.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E3794DA11B9B6D70011C497 /* libThree20Network.a */; }; @@ -408,6 +418,12 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 664DFEF212663122004C20C2 /* TTCatalog-v3.2.5.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TTCatalog-v3.2.5.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 665E998712662FFA0025FA42 /* TTCatalog-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "TTCatalog-Info.plist"; sourceTree = ""; }; + 666E182E12944D23001C1D97 /* SplitCatalogController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitCatalogController.h; sourceTree = ""; }; + 666E182F12944D23001C1D97 /* SplitCatalogController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SplitCatalogController.m; sourceTree = ""; }; + 6675F5F012945622008DE0A6 /* Default-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape.png"; path = "../Resources/Default-Landscape.png"; sourceTree = SOURCE_ROOT; }; + 6675F5F112945622008DE0A6 /* Default-Portrait.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait.png"; path = "../Resources/Default-Portrait.png"; sourceTree = SOURCE_ROOT; }; + 6675F5F212945622008DE0A6 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../Resources/Default@2x.png"; sourceTree = SOURCE_ROOT; }; + 6675F5F312945622008DE0A6 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "../Resources/Icon@2x.png"; sourceTree = SOURCE_ROOT; }; 6E002565116A6D1A00D1F0CB /* TableWithShadowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWithShadowController.h; sourceTree = ""; }; 6E002566116A6D1A00D1F0CB /* TableWithShadowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableWithShadowController.m; sourceTree = ""; }; 6E3794BF11B9B6D70011C497 /* Three20Core.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Three20Core.xcodeproj; path = ../../src/Three20Core/Three20Core.xcodeproj; sourceTree = SOURCE_ROOT; }; @@ -521,6 +537,8 @@ children = ( 1D3623240D0F684500981E51 /* AppDelegate.h */, 1D3623250D0F684500981E51 /* AppDelegate.m */, + 666E182E12944D23001C1D97 /* SplitCatalogController.h */, + 666E182F12944D23001C1D97 /* SplitCatalogController.m */, 28C286DF0D94DF7D0034E888 /* CatalogController.h */, 28C286E00D94DF7D0034E888 /* CatalogController.m */, EA1080F1101B37E90098AAC2 /* Photos */, @@ -571,6 +589,10 @@ children = ( BEDCFBB30F4FFF820060B7D1 /* Three20.bundle */, 6E94C6AB116D98220012B12C /* Default.png */, + 6675F5F012945622008DE0A6 /* Default-Landscape.png */, + 6675F5F112945622008DE0A6 /* Default-Portrait.png */, + 6675F5F212945622008DE0A6 /* Default@2x.png */, + 6675F5F312945622008DE0A6 /* Icon@2x.png */, 6E94C6AC116D98220012B12C /* Icon.png */, BEA6BAAC101436AC00B83B3A /* defaultMusic.png */, BEA6BA7E101431DA00B83B3A /* defaultPerson.png */, @@ -1272,6 +1294,10 @@ BEA6BAAD101436AC00B83B3A /* defaultMusic.png in Resources */, 6E94C6AD116D98220012B12C /* Default.png in Resources */, 6E94C6AE116D98220012B12C /* Icon.png in Resources */, + 6675F5F412945622008DE0A6 /* Default-Landscape.png in Resources */, + 6675F5F512945622008DE0A6 /* Default-Portrait.png in Resources */, + 6675F5F612945622008DE0A6 /* Default@2x.png in Resources */, + 6675F5F712945622008DE0A6 /* Icon@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1288,6 +1314,10 @@ 664DFEC712663122004C20C2 /* defaultMusic.png in Resources */, 664DFEC812663122004C20C2 /* Default.png in Resources */, 664DFEC912663122004C20C2 /* Icon.png in Resources */, + 6675F5F812945622008DE0A6 /* Default-Landscape.png in Resources */, + 6675F5F912945622008DE0A6 /* Default-Portrait.png in Resources */, + 6675F5FA12945622008DE0A6 /* Default@2x.png in Resources */, + 6675F5FB12945622008DE0A6 /* Icon@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1323,6 +1353,7 @@ BEC787631040A430005C00CF /* LauncherViewTestController.m in Sources */, 6E002567116A6D1A00D1F0CB /* TableWithShadowController.m in Sources */, E46662FE127F91A4001A0F20 /* TableWithBannerController.m in Sources */, + 666E183012944D23001C1D97 /* SplitCatalogController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1355,6 +1386,7 @@ 664DFEE112663122004C20C2 /* LauncherViewTestController.m in Sources */, 664DFEE212663122004C20C2 /* TableWithShadowController.m in Sources */, 664B27F612846A220008D569 /* TableWithBannerController.m in Sources */, + 666E183112944D23001C1D97 /* SplitCatalogController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1438,6 +1470,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6E7F9960118E3A6000443B46 /* App.xcconfig */; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; @@ -1445,6 +1478,7 @@ GCC_PREPROCESSOR_DEFINITIONS = DEBUG; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -1452,10 +1486,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6E7F9960118E3A6000443B46 /* App.xcconfig */; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -1463,6 +1499,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6E7F9960118E3A6000443B46 /* App.xcconfig */; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; @@ -1480,6 +1517,7 @@ PRODUCT_NAME = "$(BASE_PRODUCT_NAME)-v3.2.5"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -1487,6 +1525,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6E7F9960118E3A6000443B46 /* App.xcconfig */; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; OTHER_LDFLAGS = ( @@ -1501,6 +1540,7 @@ PRODUCT_NAME = "$(BASE_PRODUCT_NAME)-v3.2.5"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; };