From 875bb1af1f74ec2e455b537eec53f5b25c908a59 Mon Sep 17 00:00:00 2001 From: Robert Brown Date: Sat, 3 May 2014 14:34:51 -0600 Subject: [PATCH] Introduced a new way to link storyboards. --- .gitignore | 2 + .../RBStoryboardLink.h | 0 .../RBStoryboardLink.m | 0 .../RBStoryboardLinkSource.h | 0 Classes/RBStoryboardModalSegue.h | 35 +++++++++ Classes/RBStoryboardModalSegue.m | 39 ++++++++++ Classes/RBStoryboardPopoverSegue.h | 29 ++++++++ Classes/RBStoryboardPopoverSegue.m | 44 +++++++++++ Classes/RBStoryboardPushSegue.h | 29 ++++++++ Classes/RBStoryboardPushSegue.m | 43 +++++++++++ Classes/RBStoryboardSegue.h | 35 +++++++++ Classes/RBStoryboardSegue.m | 65 ++++++++++++++++ Classes/UIViewController+RBStoryboardLink.h | 43 +++++++++++ Classes/UIViewController+RBStoryboardLink.m | 42 +++++++++++ .../LSChooseViewController.m | 2 +- .../SecondaryStoryboard.storyboard | 10 +-- .../en.lproj/MainStoryboard.storyboard | 74 +++++-------------- LinkedStoryboards/Podfile.lock | 6 +- LinkedTabs/Podfile.lock | 6 +- RBStoryboardLink.podspec | 18 ++--- README.md | 9 ++- UIViewController+RBStoryboardLink.h | 27 ------- UIViewController+RBStoryboardLink.m | 26 ------- 23 files changed, 451 insertions(+), 133 deletions(-) rename RBStoryboardLink.h => Classes/RBStoryboardLink.h (100%) rename RBStoryboardLink.m => Classes/RBStoryboardLink.m (100%) rename RBStoryboardLinkSource.h => Classes/RBStoryboardLinkSource.h (100%) create mode 100644 Classes/RBStoryboardModalSegue.h create mode 100644 Classes/RBStoryboardModalSegue.m create mode 100644 Classes/RBStoryboardPopoverSegue.h create mode 100644 Classes/RBStoryboardPopoverSegue.m create mode 100644 Classes/RBStoryboardPushSegue.h create mode 100644 Classes/RBStoryboardPushSegue.m create mode 100644 Classes/RBStoryboardSegue.h create mode 100644 Classes/RBStoryboardSegue.m create mode 100644 Classes/UIViewController+RBStoryboardLink.h create mode 100644 Classes/UIViewController+RBStoryboardLink.m delete mode 100644 UIViewController+RBStoryboardLink.h delete mode 100644 UIViewController+RBStoryboardLink.m diff --git a/.gitignore b/.gitignore index 075c190..bba4b41 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ xcuserdata /LinkedTabs/Pods/ /LinkedStoryboards/Pods/ + +.DS_Store diff --git a/RBStoryboardLink.h b/Classes/RBStoryboardLink.h similarity index 100% rename from RBStoryboardLink.h rename to Classes/RBStoryboardLink.h diff --git a/RBStoryboardLink.m b/Classes/RBStoryboardLink.m similarity index 100% rename from RBStoryboardLink.m rename to Classes/RBStoryboardLink.m diff --git a/RBStoryboardLinkSource.h b/Classes/RBStoryboardLinkSource.h similarity index 100% rename from RBStoryboardLinkSource.h rename to Classes/RBStoryboardLinkSource.h diff --git a/Classes/RBStoryboardModalSegue.h b/Classes/RBStoryboardModalSegue.h new file mode 100644 index 0000000..7cc5b6f --- /dev/null +++ b/Classes/RBStoryboardModalSegue.h @@ -0,0 +1,35 @@ +// +// RBStoryboardModalSegue.h +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardSegue.h" + +@interface RBStoryboardModalSegue : RBStoryboardSegue + +@property (nonatomic, assign) UIModalPresentationStyle presentationStyle; + +@property (nonatomic, assign) UIModalTransitionStyle transitionStyle; + +@property (nonatomic, copy) dispatch_block_t completion; + +@end diff --git a/Classes/RBStoryboardModalSegue.m b/Classes/RBStoryboardModalSegue.m new file mode 100644 index 0000000..dea41c4 --- /dev/null +++ b/Classes/RBStoryboardModalSegue.m @@ -0,0 +1,39 @@ +// +// RBStoryboardModalSegue.m +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardModalSegue.h" + +@implementation RBStoryboardModalSegue + +- (void)perform { + + [self.destinationViewController setModalPresentationStyle:self.presentationStyle]; + [self.destinationViewController setModalTransitionStyle:self.transitionStyle]; + + [self.sourceViewController presentViewController:self.destinationViewController + animated:self.animated + completion:self.completion]; +} + +@end diff --git a/Classes/RBStoryboardPopoverSegue.h b/Classes/RBStoryboardPopoverSegue.h new file mode 100644 index 0000000..b134821 --- /dev/null +++ b/Classes/RBStoryboardPopoverSegue.h @@ -0,0 +1,29 @@ +// +// RBStoryboardPopoverSegue.h +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +@interface RBStoryboardPopoverSegue : UIStoryboardPopoverSegue + +@end diff --git a/Classes/RBStoryboardPopoverSegue.m b/Classes/RBStoryboardPopoverSegue.m new file mode 100644 index 0000000..a7c1033 --- /dev/null +++ b/Classes/RBStoryboardPopoverSegue.m @@ -0,0 +1,44 @@ +// +// RBStoryboardPopoverSegue.m +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardPopoverSegue.h" +#import "RBStoryboardSegue.h" +#import "RBStoryboardLink.h" + +@implementation RBStoryboardPopoverSegue + +- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination +{ + NSAssert([destination isKindOfClass:[RBStoryboardLink class]], @"RBStoryboardSegue can only be used with a RBStoryboardLink as seque destination."); + + UIViewController * newDestination = [RBStoryboardSegue viewControllerFromLink:(RBStoryboardLink *)destination]; + + if ((self = [super initWithIdentifier:identifier source:source destination:newDestination])) { + + } + + return self; +} + +@end diff --git a/Classes/RBStoryboardPushSegue.h b/Classes/RBStoryboardPushSegue.h new file mode 100644 index 0000000..6dde036 --- /dev/null +++ b/Classes/RBStoryboardPushSegue.h @@ -0,0 +1,29 @@ +// +// RBStoryboardPushSegue.h +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardSegue.h" + +@interface RBStoryboardPushSegue : RBStoryboardSegue + +@end diff --git a/Classes/RBStoryboardPushSegue.m b/Classes/RBStoryboardPushSegue.m new file mode 100644 index 0000000..9271e1b --- /dev/null +++ b/Classes/RBStoryboardPushSegue.m @@ -0,0 +1,43 @@ +// +// RBStoryboardPushSegue.m +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardPushSegue.h" + +@implementation RBStoryboardPushSegue + +- (void)perform { + + UINavigationController * navController = nil; + + if ([self.sourceViewController isKindOfClass:[UINavigationController class]]) { + navController = self.sourceViewController; + } + else { + navController = [self.sourceViewController navigationController]; + } + + [navController pushViewController:self.destinationViewController animated:self.animated]; +} + +@end diff --git a/Classes/RBStoryboardSegue.h b/Classes/RBStoryboardSegue.h new file mode 100644 index 0000000..90e0819 --- /dev/null +++ b/Classes/RBStoryboardSegue.h @@ -0,0 +1,35 @@ +// +// RBStoryboardSegue.h +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +@class RBStoryboardLink; + +@interface RBStoryboardSegue : UIStoryboardSegue + +@property (nonatomic, assign, getter = isAnimated) BOOL animated; + ++ (UIViewController *)viewControllerFromLink:(RBStoryboardLink *)link; + +@end diff --git a/Classes/RBStoryboardSegue.m b/Classes/RBStoryboardSegue.m new file mode 100644 index 0000000..cf763bd --- /dev/null +++ b/Classes/RBStoryboardSegue.m @@ -0,0 +1,65 @@ +// +// RBStoryboardSegue.m +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "RBStoryboardSegue.h" +#import "RBStoryboardLink.h" + + +@implementation RBStoryboardSegue + ++ (UIViewController *)viewControllerFromLink:(RBStoryboardLink *)link { + + NSParameterAssert(link); + + // Grabs the user-defined runtime attributes. + NSString * storyboardName = [(RBStoryboardLink *)link storyboardName]; + NSString * storyboardID = [(RBStoryboardLink *)link sceneIdentifier]; + + NSAssert(storyboardName, @"Unable to load linked storyboard. RBStoryboardLink storyboardName is nil. Forgot to set attribute in interface builder?"); + + // Creates new destination. + UIStoryboard * storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; + + if ([storyboardID length] == 0) { + return [storyboard instantiateInitialViewController]; + } + else { + return [storyboard instantiateViewControllerWithIdentifier:storyboardID]; + } +} + +- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination +{ + NSAssert([destination isKindOfClass:[RBStoryboardLink class]], @"RBStoryboardSegue can only be used with a RBStoryboardLink as seque destination."); + + UIViewController * newDestination = [[self class] viewControllerFromLink:(RBStoryboardLink *)destination]; + + if ((self = [super initWithIdentifier:identifier source:source destination:newDestination])) { + _animated = YES; + } + + return self; +} + +@end diff --git a/Classes/UIViewController+RBStoryboardLink.h b/Classes/UIViewController+RBStoryboardLink.h new file mode 100644 index 0000000..0ebfbed --- /dev/null +++ b/Classes/UIViewController+RBStoryboardLink.h @@ -0,0 +1,43 @@ +// +// UIViewController+RBStoryboardLink.h +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import + +@class RBStoryboardLink; + + +@interface UIViewController (RBStoryboardLink) + +/// Returns the storyboard link this view controller is contained in, if any. +- (RBStoryboardLink *)rbsl_storyboardLink; + +/** + * If the view controller is within a storyboard link, the link is returned. + * If not, `self` is returned. The intent is to access certain visual elements + * (such as `toolbarItems`) on the proper view controller when it's unknown if + * the view controller is contained in a link. + */ +- (UIViewController *)rbsl_targetViewController; + +@end diff --git a/Classes/UIViewController+RBStoryboardLink.m b/Classes/UIViewController+RBStoryboardLink.m new file mode 100644 index 0000000..3a640d2 --- /dev/null +++ b/Classes/UIViewController+RBStoryboardLink.m @@ -0,0 +1,42 @@ +// +// UIViewController+RBStoryboardLink.m +// +// Copyright (c) 2012-2014 Robert Brown +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#import "UIViewController+RBStoryboardLink.h" +#import "RBStoryboardLink.h" + +@implementation UIViewController (RBStoryboardLink) + +- (RBStoryboardLink *)rbsl_storyboardLink { + + if ([self isKindOfClass:[RBStoryboardLink class]]) + return (RBStoryboardLink *)self; + + return [self.parentViewController rbsl_storyboardLink]; +} + +- (UIViewController *)rbsl_targetViewController { + return [self rbsl_storyboardLink] ?: self; +} + +@end diff --git a/LinkedStoryboards/LinkedStoryboards/LSChooseViewController.m b/LinkedStoryboards/LinkedStoryboards/LSChooseViewController.m index 876a988..ff828a3 100644 --- a/LinkedStoryboards/LinkedStoryboards/LSChooseViewController.m +++ b/LinkedStoryboards/LinkedStoryboards/LSChooseViewController.m @@ -36,7 +36,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - id scene = [[segue destinationViewController] scene]; + id scene = [segue destinationViewController]; if ([scene isKindOfClass:[LSParameterReceivingViewController class]]) { LSParameterReceivingViewController * vc = (LSParameterReceivingViewController *)scene; diff --git a/LinkedStoryboards/LinkedStoryboards/SecondaryStoryboard.storyboard b/LinkedStoryboards/LinkedStoryboards/SecondaryStoryboard.storyboard index 25d5cc1..edc12ec 100644 --- a/LinkedStoryboards/LinkedStoryboards/SecondaryStoryboard.storyboard +++ b/LinkedStoryboards/LinkedStoryboards/SecondaryStoryboard.storyboard @@ -1,8 +1,8 @@ - + - + @@ -72,7 +72,7 @@ - + - - - - - - - - - - - - - - - - - - \ No newline at end of file + diff --git a/LinkedStoryboards/Podfile.lock b/LinkedStoryboards/Podfile.lock index 5b3c4ae..8494413 100644 --- a/LinkedStoryboards/Podfile.lock +++ b/LinkedStoryboards/Podfile.lock @@ -1,6 +1,6 @@ PODS: - KIF (2.0.0) - - RBStoryboardLink (0.0.8) + - RBStoryboardLink (0.1.0) DEPENDENCIES: - KIF (~> 2.0) @@ -12,6 +12,6 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: KIF: c01fb8fb593cf8ffeeb69ed8d402ce88143e0697 - RBStoryboardLink: 1bcff9be9fa9de9d66ea10518a327be1af729d03 + RBStoryboardLink: ab20204dad0e4752720abdee4cb317c67ea0afbc -COCOAPODS: 0.31.1 +COCOAPODS: 0.32.1 diff --git a/LinkedTabs/Podfile.lock b/LinkedTabs/Podfile.lock index 5b3c4ae..8494413 100644 --- a/LinkedTabs/Podfile.lock +++ b/LinkedTabs/Podfile.lock @@ -1,6 +1,6 @@ PODS: - KIF (2.0.0) - - RBStoryboardLink (0.0.8) + - RBStoryboardLink (0.1.0) DEPENDENCIES: - KIF (~> 2.0) @@ -12,6 +12,6 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: KIF: c01fb8fb593cf8ffeeb69ed8d402ce88143e0697 - RBStoryboardLink: 1bcff9be9fa9de9d66ea10518a327be1af729d03 + RBStoryboardLink: ab20204dad0e4752720abdee4cb317c67ea0afbc -COCOAPODS: 0.31.1 +COCOAPODS: 0.32.1 diff --git a/RBStoryboardLink.podspec b/RBStoryboardLink.podspec index 2e281cc..fe95e68 100644 --- a/RBStoryboardLink.podspec +++ b/RBStoryboardLink.podspec @@ -1,20 +1,20 @@ Pod::Spec.new do |s| s.name = 'RBStoryboardLink' - s.version = '0.0.8' + s.version = '0.1.0' s.summary = 'Makes transitioning between storyboards possible.' s.homepage = 'https://github.com/rob-brown/RBStoryboardLink' - s.license = { - :type => 'MIT', - :file => 'LICENSE' + s.license = { + :type => 'MIT', + :file => 'LICENSE' } s.author = 'Robert Brown' - s.source = { - :git => 'https://github.com/rob-brown/RBStoryboardLink.git', - :tag => '0.0.8' + s.source = { + :git => 'https://github.com/rob-brown/RBStoryboardLink.git', + :tag => s.version } s.platform = :ios, '7.0' - s.source_files = 'RBStoryboardLink.{h,m}', 'UIViewController+RBStoryboardLink.{h,m}', 'RBStoryboardLinkSource.h' - s.public_header_files = 'RBStoryboardLink.h', 'UIViewController+RBStoryboardLink.h', 'RBStoryboardLinkSource.h' + s.source_files = 'Classes/*.{h,m}' + s.public_header_files = 'Classes/*.h' s.frameworks = 'UIKit' s.requires_arc = true end diff --git a/README.md b/README.md index ac33195..3cf3649 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ ## How to use +**NOTE:** As of 0.1.0, there is a new workflow. The old workflow only used `RBStoryboardLink`. It was responsible for all the work by acting as a proxy for the real view controller. In the new workflow, `RBStoryboardLink` merely provides information for `RBStoryboardSegue`. `RBStoryboardSegue` redirects the segue on presentation. This redirection avoids the complexity of `UIViewController` containment and dereferencing a proxy in methods such as `-prepareForSegue:sender:`. The new workflow is thanks to [@MBulli][3]. + 1. Your app's storyboards must first be decomposed into their natural modules. See this [guide][1] for some tips. 2. Where ever you want create a transition into a different storyboard, create a `UIViewController` representing the scene to be pushed. -3. Create the desired segue type (Push, Modal, Custom) to these surrogate view controllers. +3. Create the desired segue type (Push, Modal, Custom) to these surrogate view controllers. To take advantage of the new linking, set the type to custom and choose one of `RBStoryboardPushSegue`, `RBStoryboardModalSegue`, or `RBStoryboardPopoverSegue`. You may also create subclasses of `RBStoryboardSegue` for custom transitions. 4. In the Identity Inspector, change the class type of each surrogate view controller to `RBStoryboardLink`. @@ -22,8 +24,8 @@ 1. storyboardName (Required) The name of the storyboard to transition into. 2. sceneIdentifier (Optional) The identifier of the view controller to transition to. If left blank, this will push the first view controller. - 3. needsTopLayoutGuide (Optional) Whether a custom layout constraint should be added to the top layout guide in storyboards. If you notice the background of your navigation bar not getting behind the status bar, set this to `NO`. - 4. needsBottomLayoutGuide (Optional) Same as the one on top, but for the bottom guide. + 3. needsTopLayoutGuide (Optional) Whether a custom layout constraint should be added to the top layout guide in storyboards. If you notice the background of your navigation bar not getting behind the status bar, set this to `NO`. This property is unused if using one of the `RBStoryboardSegue`s. + 4. needsBottomLayoutGuide (Optional) Same as the one on top, but for the bottom guide. This property is unused if using one of the `RBStoryboardSegue`s. ## Implementation notes @@ -67,3 +69,4 @@ Contributions are welcomed. I'm much more responsive to pull requests rather tha [1]: http://robsprogramknowledge.blogspot.com/2012/01/uistoryboard-best-practices.html [2]: https://github.com/kif-framework/KIF + [3]: https://github.com/MBulli diff --git a/UIViewController+RBStoryboardLink.h b/UIViewController+RBStoryboardLink.h deleted file mode 100644 index 509b161..0000000 --- a/UIViewController+RBStoryboardLink.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// UIViewController+RBStoryboardLink.h -// Pods -// -// Created by Robert Brown on 1/25/14. -// -// - -#import - -@class RBStoryboardLink; - - -@interface UIViewController (RBStoryboardLink) - -/// Returns the storyboard link this view controller is contained in, if any. -- (RBStoryboardLink *)rbsl_storyboardLink; - -/** - * If the view controller is within a storyboard link, the link is returned. - * If not, `self` is returned. The intent is to access certain visual elements - * (such as `toolbarItems`) on the proper view controller when it's unknown if - * the view controller is contained in a link. - */ -- (UIViewController *)rbsl_targetViewController; - -@end diff --git a/UIViewController+RBStoryboardLink.m b/UIViewController+RBStoryboardLink.m deleted file mode 100644 index 4538edc..0000000 --- a/UIViewController+RBStoryboardLink.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// UIViewController+RBStoryboardLink.m -// Pods -// -// Created by Robert Brown on 1/25/14. -// -// - -#import "UIViewController+RBStoryboardLink.h" -#import "RBStoryboardLink.h" - -@implementation UIViewController (RBStoryboardLink) - -- (RBStoryboardLink *)rbsl_storyboardLink { - - if ([self isKindOfClass:[RBStoryboardLink class]]) - return (RBStoryboardLink *)self; - - return [self.parentViewController rbsl_storyboardLink]; -} - -- (UIViewController *)rbsl_targetViewController { - return [self rbsl_storyboardLink] ?: self; -} - -@end