├── Sample Projects ├── SFContainerViewController │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── SFLoggingViewController.h │ ├── SFRandomContainerViewController.h │ ├── SFAppDelegate.h │ ├── SFRandomContainerView.h │ ├── main.m │ ├── SFContainerViewController-Prefix.pch │ ├── SFRandomContainerView.m │ ├── SFContainerViewController-Info.plist │ ├── SFLoggingViewController.m │ ├── SFRandomContainerViewController.m │ └── SFAppDelegate.m └── SFContainerViewController.xcodeproj │ ├── xcuserdata │ ├── roche.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints.xcbkptlist │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── SFContainerViewController.xcscheme │ ├── krzysztof.zablocki.xcuserdatad │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── SFContainerViewController.xcscheme │ └── merowing2.xcuserdatad │ │ └── xcschemes │ │ └── SFContainerViewController.xcscheme │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── roche.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── WorkspaceSettings.xcsettings │ └── project.pbxproj ├── Sample Projects ARC ├── SFContainerViewController │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── SFLoggingViewController.h │ ├── SFRandomContainerViewController.h │ ├── SFAppDelegate.h │ ├── SFRandomContainerView.h │ ├── main.m │ ├── SFContainerViewController-Prefix.pch │ ├── SFRandomContainerView.m │ ├── SFContainerViewController-Info.plist │ ├── SFRandomContainerViewController.m │ ├── SFLoggingViewController.m │ └── SFAppDelegate.m └── SFContainerViewController.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ ├── xcuserdata │ ├── roche.xcuserdatad │ │ └── xcschemes │ │ │ └── SFContainerViewController.xcscheme │ ├── merowing2.xcuserdatad │ │ └── xcschemes │ │ │ └── SFContainerViewController.xcscheme │ └── krzysztof.zablocki.xcuserdatad │ │ └── xcschemes │ │ └── SFContainerViewController.xcscheme │ └── project.pbxproj ├── .gitignore ├── LICENCE.txt ├── README.md └── ContainerViewController ├── SFContainerViewController.h └── SFContainerViewController.m /Sample Projects/SFContainerViewController/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/roche.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/project.xcworkspace/xcuserdata/roche.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krzysztofzablocki/SFContainerViewController/HEAD/Sample Projects/SFContainerViewController.xcodeproj/project.xcworkspace/xcuserdata/roche.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFLoggingViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFLoggingViewController.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFLoggingViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFLoggingViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFLoggingViewController.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFLoggingViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFRandomContainerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RandomContainerViewController.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFContainerViewController.h" 10 | 11 | @interface SFRandomContainerViewController : SFContainerViewController 12 | @end 13 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFRandomContainerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RandomContainerViewController.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFContainerViewController.h" 10 | 11 | @interface SFRandomContainerViewController : SFContainerViewController 12 | @end 13 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFAppDelegate.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFAppDelegate.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFRandomContainerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFRandomContainerView.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFRandomContainerView : UIView 12 | @property (nonatomic, assign) int rows; 13 | @property (nonatomic, assign) int columns; 14 | @end 15 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFRandomContainerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFRandomContainerView.h 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SFRandomContainerView : UIView 12 | @property (nonatomic, assign) int rows; 13 | @property (nonatomic, assign) int columns; 14 | @end 15 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "SFAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([SFAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "SFAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([SFAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFContainerViewController-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SFContainerViewController' target in the 'SFContainerViewController' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFContainerViewController-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SFContainerViewController' target in the 'SFContainerViewController' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/project.xcworkspace/xcuserdata/roche.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/roche.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SFContainerViewController.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1B13465A14F7A3530029CB60 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/krzysztof.zablocki.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SFContainerViewController.xcscheme 8 | 9 | orderHint 10 | 103 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1B13465A14F7A3530029CB60 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # found at http://blog.illuminex.com/2009/10/better-sample-gitignore-file-for-xcode.html 2 | # Mac OS X Finder and whatnot 3 | .DS_Store 4 | 5 | 6 | # Sparkle distribution Private Key (Don't check me in!) 7 | dsa_priv.pem 8 | 9 | 10 | # XCode (and ancestors) per-user config (very noisy, and not relevant) 11 | *.mode1 12 | *.mode1v3 13 | *.mode2v3 14 | *.perspective 15 | *.perspectivev3 16 | *.pbxuser 17 | *.xcuserdata 18 | 19 | # Generated files 20 | VersionX-revision.h 21 | 22 | 23 | # build products 24 | build/ 25 | *.[oa] 26 | 27 | 28 | # Other source repository archive directories (protects when importing) 29 | .hg 30 | .svn 31 | CVS 32 | 33 | 34 | # automatic backup files 35 | *~.nib 36 | *.swp 37 | *~ 38 | *(Autosaved).rtfd/ 39 | Backup[ ]of[ ]*.pages/ 40 | Backup[ ]of[ ]*.key/ 41 | Backup[ ]of[ ]*.numbers/ 42 | *.xcuserstate 43 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFRandomContainerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFRandomContainerView.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFRandomContainerView.h" 10 | 11 | @implementation SFRandomContainerView 12 | @synthesize rows; 13 | @synthesize columns; 14 | 15 | - (id)initWithFrame:(CGRect)frame 16 | { 17 | self = [super initWithFrame:frame]; 18 | if (self) { 19 | // Initialization code 20 | } 21 | return self; 22 | } 23 | 24 | 25 | - (void)layoutSubviews 26 | { 27 | int widthSize = self.bounds.size.width / columns; 28 | int heightSize = self.bounds.size.height / rows; 29 | int index = 0; 30 | for (int x = 0; x < columns; ++x) { 31 | for (int y = 0; y < rows; ++y) { 32 | UIView *subview = [self.subviews objectAtIndex:index++]; 33 | subview.frame = CGRectMake(x * widthSize, y * heightSize, widthSize, heightSize); 34 | } 35 | } 36 | } 37 | @end 38 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFRandomContainerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFRandomContainerView.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFRandomContainerView.h" 10 | 11 | @implementation SFRandomContainerView 12 | @synthesize rows; 13 | @synthesize columns; 14 | 15 | - (id)initWithFrame:(CGRect)frame 16 | { 17 | self = [super initWithFrame:frame]; 18 | if (self) { 19 | // Initialization code 20 | } 21 | return self; 22 | } 23 | 24 | - (void)dealloc 25 | { 26 | [super dealloc]; 27 | } 28 | 29 | - (void)layoutSubviews 30 | { 31 | int widthSize = self.bounds.size.width / columns; 32 | int heightSize = self.bounds.size.height / rows; 33 | int index = 0; 34 | for (int x = 0; x < columns; ++x) { 35 | for (int y = 0; y < rows; ++y) { 36 | UIView *subview = [self.subviews objectAtIndex:index++]; 37 | subview.frame = CGRectMake(x * widthSize, y * heightSize, widthSize, heightSize); 38 | } 39 | } 40 | } 41 | @end 42 | -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * SFContainerViewController for cocos2d: http://merowing.info 3 | * 4 | * Copyright (c) 2012 Krzysztof Zabłocki 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### UPDATE: I'm no longer using SFContainerViewControllers in any project, it was created way before there was native view controller contaiment in iOS, it's been a long time since Apple added it as part of the system, you should use Apple's implementation. 2 | 3 | Purpose 4 | -------------- 5 | 6 | SFContainerViewController is a UIViewController subclass that can have multiple UIViewController children. No memory problems, if this controller is not visible, it will unload its view and all of his children views. 7 | From the children view you can use freely navigationController, parentViewController ( will point to container itself ), interfaceOrientation. 8 | 9 | [Follow me on twitter][1] 10 | 11 | Supported OS & SDK Versions 12 | ----------------------------- 13 | 14 | * iOS 4.0 (Xcode 4.3, Apple LLVM compiler 3.1) 15 | 16 | ARC Compatibility 17 | ------------------ 18 | 19 | SFContainerViewController automatically works with both ARC and non-ARC projects through conditional compilation. There is no need to exclude SFContainerViewController files from the ARC validation process, or to convert CCNode+SFGestureRecognizers using the ARC conversion tool. 20 | 21 | Installation 22 | -------------- 23 | 24 | To use the SFContainerViewController class in an app, just drag the class files (demo files and assets are not needed) into your project. 25 | 26 | Just subclass from SFContainerViewController, set viewControllers to your selected controllers and implement loadView so that you can have your own view to layout your controllers. 27 | 28 | Properties 29 | -------------- 30 | 31 | @property (nonatomic, copy) NSArray *viewControllers; 32 | Children view controllers of this container. 33 | 34 | [1]: http://twitter.com/merowing_ 35 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFContainerViewController-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | pl.simplify.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFContainerViewController-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | pl.simplify.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFLoggingViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFLoggingViewController.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | #import 9 | #import "SFLoggingViewController.h" 10 | 11 | @implementation SFLoggingViewController 12 | 13 | - (void)loadView 14 | { 15 | [super loadView]; 16 | self.view.layer.borderWidth = 1; 17 | self.view.layer.borderColor = [UIColor greenColor].CGColor; 18 | } 19 | 20 | - (void)viewDidUnload 21 | { 22 | [super viewDidUnload]; 23 | NSLog(@"child view controller %@ just unloaded its view", self); 24 | } 25 | 26 | - (void)viewDidAppear:(BOOL)animated 27 | { 28 | [super viewDidAppear:animated]; 29 | NSLog(@"child view controller %@ appeared, self.parentController is %@", self, self.parentViewController); 30 | } 31 | 32 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 33 | { 34 | [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 35 | NSLog(@"child view controller will rotate from %d to %d", self.interfaceOrientation, toInterfaceOrientation); 36 | } 37 | 38 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 39 | { 40 | [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 41 | NSLog(@"child view controller did rotate from %d to %d", fromInterfaceOrientation, self.interfaceOrientation); 42 | } 43 | 44 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 45 | { 46 | // Return YES for supported orientations 47 | return YES; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFRandomContainerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RandomContainerViewController.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFRandomContainerViewController.h" 10 | #import "SFRandomContainerView.h" 11 | #import "SFLoggingViewController.h" 12 | 13 | @implementation SFRandomContainerViewController 14 | - (id)init 15 | { 16 | self = [super init]; 17 | if (self) { 18 | static int count = 0; 19 | self.tabBarItem.title = [NSString stringWithFormat:@"Controller%d", ++count]; 20 | } 21 | return self; 22 | } 23 | 24 | - (void)loadView 25 | { 26 | int columns = arc4random() % 4 + 2; 27 | int rows = arc4random() % 3 + 3; 28 | 29 | //! just some random child controllers generation 30 | SFRandomContainerView *containerView = [[SFRandomContainerView alloc] init]; 31 | self.view = containerView; 32 | containerView.rows = rows; 33 | containerView.columns = columns; 34 | 35 | NSMutableArray *viewControllers = [NSMutableArray arrayWithCapacity:columns * rows]; 36 | for (int i = 0; i < columns * rows; ++i) { 37 | SFLoggingViewController *randomController = [[SFLoggingViewController alloc] init]; 38 | randomController.view.backgroundColor = [UIColor colorWithRed:((arc4random() % 255) / 255.0f) green:((arc4random() % 255) / 255.0f) blue:((arc4random() % 255) / 255.0f) alpha:1]; 39 | [containerView addSubview:randomController.view]; 40 | [viewControllers addObject:randomController]; 41 | } 42 | 43 | [self setViewControllers:viewControllers]; 44 | } 45 | 46 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 47 | { 48 | // Return YES for supported orientations 49 | return YES; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFRandomContainerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RandomContainerViewController.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFRandomContainerViewController.h" 10 | #import "SFRandomContainerView.h" 11 | #import "SFLoggingViewController.h" 12 | 13 | @implementation SFRandomContainerViewController 14 | - (id)init 15 | { 16 | self = [super init]; 17 | if (self) { 18 | static int count = 0; 19 | self.tabBarItem.title = [NSString stringWithFormat:@"Controller%d", ++count]; 20 | } 21 | return self; 22 | } 23 | 24 | - (void)loadView 25 | { 26 | int columns = arc4random() % 4 + 2; 27 | int rows = arc4random() % 3 + 3; 28 | 29 | //! just some random child controllers generation 30 | SFRandomContainerView *containerView = [[[SFRandomContainerView alloc] init] autorelease]; 31 | self.view = containerView; 32 | containerView.rows = rows; 33 | containerView.columns = columns; 34 | 35 | NSMutableArray *viewControllers = [NSMutableArray arrayWithCapacity:columns * rows]; 36 | for (int i = 0; i < columns * rows; ++i) { 37 | SFLoggingViewController *randomController = [[SFLoggingViewController alloc] init]; 38 | randomController.view.backgroundColor = [UIColor colorWithRed:((arc4random() % 255) / 255.0f) green:((arc4random() % 255) / 255.0f) blue:((arc4random() % 255) / 255.0f) alpha:1]; 39 | [containerView addSubview:randomController.view]; 40 | [viewControllers addObject:randomController]; 41 | [randomController release]; 42 | } 43 | 44 | [self setViewControllers:viewControllers]; 45 | } 46 | 47 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 48 | { 49 | // Return YES for supported orientations 50 | return YES; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /ContainerViewController/SFContainerViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SFContainerViewController for cocos2d: http://merowing.info 3 | * 4 | * Copyright (c) 2012 Krzysztof Zabłocki 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | #import 26 | 27 | //! Controller used to contain multiple view controllers 28 | @interface SFContainerViewController : UIViewController { 29 | @private 30 | NSArray *viewControllers; 31 | } 32 | @property (nonatomic, copy) NSArray *viewControllers; 33 | @end 34 | 35 | // This protocol added to prevent "Semantic issue: undeclared selector" compiler warning 36 | // http://stackoverflow.com/questions/18570907/should-i-fix-xcode-5-semantic-issue-undeclared-selector 37 | @protocol SFContainerViewControllerSelectors 38 | - (void) sf_originalNavigationController; 39 | - (void) sf_originalParentViewController; 40 | - (void) sf_originalInterfaceOrientation; 41 | - (void) sf_originalPresentModalViewController:(UIViewController *)controller animated:(BOOL)animated; 42 | - (void) sf_originalDismissModalViewControllerAnimated:(BOOL)animated; 43 | @end 44 | 45 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFLoggingViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFLoggingViewController.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | #import 9 | #import "SFLoggingViewController.h" 10 | #import "SFContainerViewController.h" 11 | 12 | @implementation SFLoggingViewController 13 | 14 | - (void)loadView 15 | { 16 | [super loadView]; 17 | self.view.layer.borderWidth = 1; 18 | self.view.layer.borderColor = [UIColor greenColor].CGColor; 19 | 20 | 21 | [self.view addGestureRecognizer: [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer:)]]; 22 | } 23 | 24 | - (void)viewDidUnload 25 | { 26 | [super viewDidUnload]; 27 | NSLog(@"child view controller %@ just unloaded its view", self); 28 | } 29 | 30 | - (void)dismissModal 31 | { 32 | [self dismissModalViewControllerAnimated:YES]; 33 | } 34 | 35 | - (void)viewDidAppear:(BOOL)animated 36 | { 37 | [super viewDidAppear:animated]; 38 | NSLog(@"child view controller %@ appeared, self.parentController is %@ %@", self, self.parentViewController, self.modalViewController); 39 | 40 | //! make sure nested controllers unwind 41 | if (!self.parentViewController || [self.parentViewController isKindOfClass:[self class]]) { 42 | [self performSelector:@selector(dismissModal) withObject:nil afterDelay:1]; 43 | } 44 | } 45 | 46 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 47 | { 48 | [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 49 | NSLog(@"child view controller will rotate from %d to %d", self.interfaceOrientation, toInterfaceOrientation); 50 | } 51 | 52 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 53 | { 54 | [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 55 | NSLog(@"child view controller did rotate from %d to %d", fromInterfaceOrientation, self.interfaceOrientation); 56 | } 57 | 58 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 59 | { 60 | // Return YES for supported orientations 61 | return YES; 62 | } 63 | 64 | - (void)handleTapGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer 65 | { 66 | UIViewController *modalViewController = [[SFLoggingViewController alloc] init]; 67 | [self presentModalViewController:modalViewController animated:NO]; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController/SFAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFAppDelegate.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFAppDelegate.h" 10 | #import "SFRandomContainerViewController.h" 11 | 12 | @implementation SFAppDelegate 13 | 14 | @synthesize window = _window; 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 20 | 21 | UITabBarController *tabBarController = [[UITabBarController alloc] init]; 22 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:4]; 23 | for (int i=0; i < 4; ++i) { 24 | SFRandomContainerViewController *randomController = [[SFRandomContainerViewController alloc] init]; 25 | [array addObject:randomController]; 26 | } 27 | [tabBarController setViewControllers:array]; 28 | [self.window setRootViewController:tabBarController]; 29 | self.window.backgroundColor = [UIColor whiteColor]; 30 | [self.window makeKeyAndVisible]; 31 | return YES; 32 | } 33 | 34 | - (void)applicationWillResignActive:(UIApplication *)application 35 | { 36 | /* 37 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 38 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 39 | */ 40 | } 41 | 42 | - (void)applicationDidEnterBackground:(UIApplication *)application 43 | { 44 | /* 45 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 46 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 47 | */ 48 | } 49 | 50 | - (void)applicationWillEnterForeground:(UIApplication *)application 51 | { 52 | /* 53 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 54 | */ 55 | } 56 | 57 | - (void)applicationDidBecomeActive:(UIApplication *)application 58 | { 59 | /* 60 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 61 | */ 62 | } 63 | 64 | - (void)applicationWillTerminate:(UIApplication *)application 65 | { 66 | /* 67 | Called when the application is about to terminate. 68 | Save data if appropriate. 69 | See also applicationDidEnterBackground:. 70 | */ 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController/SFAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFAppDelegate.m 3 | // SFContainerViewController 4 | // 5 | // Created by roche on 2/24/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SFAppDelegate.h" 10 | #import "SFRandomContainerViewController.h" 11 | 12 | @implementation SFAppDelegate 13 | 14 | @synthesize window = _window; 15 | 16 | - (void)dealloc 17 | { 18 | [_window release]; 19 | [super dealloc]; 20 | } 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 23 | { 24 | self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 25 | 26 | UITabBarController *tabBarController = [[[UITabBarController alloc] init] autorelease]; 27 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:4]; 28 | for (int i=0; i < 4; ++i) { 29 | SFRandomContainerViewController *randomController = [[[SFRandomContainerViewController alloc] init] autorelease]; 30 | [array addObject:randomController]; 31 | } 32 | [tabBarController setViewControllers:array]; 33 | [self.window setRootViewController:tabBarController]; 34 | self.window.backgroundColor = [UIColor whiteColor]; 35 | [self.window makeKeyAndVisible]; 36 | return YES; 37 | } 38 | 39 | - (void)applicationWillResignActive:(UIApplication *)application 40 | { 41 | /* 42 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 43 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 44 | */ 45 | } 46 | 47 | - (void)applicationDidEnterBackground:(UIApplication *)application 48 | { 49 | /* 50 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 51 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 52 | */ 53 | } 54 | 55 | - (void)applicationWillEnterForeground:(UIApplication *)application 56 | { 57 | /* 58 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 59 | */ 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application 63 | { 64 | /* 65 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 66 | */ 67 | } 68 | 69 | - (void)applicationWillTerminate:(UIApplication *)application 70 | { 71 | /* 72 | Called when the application is about to terminate. 73 | Save data if appropriate. 74 | See also applicationDidEnterBackground:. 75 | */ 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/roche.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController.xcodeproj/xcuserdata/roche.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/merowing2.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController.xcodeproj/xcuserdata/merowing2.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController.xcodeproj/xcuserdata/krzysztof.zablocki.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/xcuserdata/krzysztof.zablocki.xcuserdatad/xcschemes/SFContainerViewController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /ContainerViewController/SFContainerViewController.m: -------------------------------------------------------------------------------- 1 | // Created by Krzysztof Zablocki on 8/26/11. 2 | // Copyright (c) 2011 private. All rights reserved. 3 | 4 | // ARC Helper 5 | // 6 | // Version 1.2.2 7 | // 8 | // Created by Nick Lockwood on 05/01/2012. 9 | // Copyright 2012 Charcoal Design 10 | // 11 | // Distributed under the permissive zlib license 12 | // Get the latest version from here: 13 | // 14 | // https://gist.github.com/1563325 15 | 16 | // Krzysztof Zabłocki Added AH_BRIDGE(x) to bridge cast to void* 17 | 18 | #ifndef AH_RETAIN 19 | #if __has_feature(objc_arc) 20 | #define AH_RETAIN(x) (x) 21 | #define AH_RELEASE(x) (void)(x) 22 | #define AH_AUTORELEASE(x) (x) 23 | #define AH_SUPER_DEALLOC (void)(0) 24 | #define AH_BRIDGE(x) ((__bridge void*)x) 25 | #else 26 | #define __AH_WEAK 27 | #define AH_WEAK assign 28 | #define AH_RETAIN(x) [(x) retain] 29 | #define AH_RELEASE(x) [(x) release] 30 | #define AH_AUTORELEASE(x) [(x) autorelease] 31 | #define AH_SUPER_DEALLOC [super dealloc] 32 | #define AH_BRIDGE(x) (x) 33 | #endif 34 | #endif 35 | 36 | // Weak reference support 37 | 38 | #ifndef AH_WEAK 39 | #if defined __IPHONE_OS_VERSION_MIN_REQUIRED 40 | #if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3 41 | #define __AH_WEAK __weak 42 | #define AH_WEAK weak 43 | #else 44 | #define __AH_WEAK __unsafe_unretained 45 | #define AH_WEAK unsafe_unretained 46 | #endif 47 | #elif defined __MAC_OS_X_VERSION_MIN_REQUIRED 48 | #if __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6 49 | #define __AH_WEAK __weak 50 | #define AH_WEAK weak 51 | #else 52 | #define __AH_WEAK __unsafe_unretained 53 | #define AH_WEAK unsafe_unretained 54 | #endif 55 | #endif 56 | #endif 57 | 58 | // ARC Helper ends 59 | 60 | 61 | #import "SFContainerViewController.h" 62 | #import 63 | #import 64 | 65 | static NSString * const SFContainerViewControllerParentControllerKey = @"SFContainerViewControllerParentControllerKey"; 66 | 67 | @implementation SFContainerViewController 68 | @synthesize viewControllers; 69 | 70 | //! swap methods of UIViewController 71 | + (void)initialize 72 | { 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | { //! navigationViewController 76 | Method replacingMethod = class_getInstanceMethod([self class], @selector(swappedNavigationController)); 77 | Method replacedMethod = class_getInstanceMethod([UIViewController class], @selector(navigationController)); 78 | class_addMethod([UIViewController class], @selector(sf_originalNavigationController), method_getImplementation(replacedMethod), method_getTypeEncoding(replacedMethod)); 79 | class_replaceMethod([UIViewController class], @selector(navigationController), method_getImplementation(replacingMethod), method_getTypeEncoding(replacingMethod)); 80 | } 81 | 82 | { //! parentViewController 83 | Method replacingMethod = class_getInstanceMethod([self class], @selector(swappedParentViewController)); 84 | Method replacedMethod = class_getInstanceMethod([UIViewController class], @selector(parentViewController)); 85 | class_addMethod([UIViewController class], @selector(sf_originalParentViewController), method_getImplementation(replacedMethod), method_getTypeEncoding(replacedMethod)); 86 | class_replaceMethod([UIViewController class], @selector(parentViewController), method_getImplementation(replacingMethod), method_getTypeEncoding(replacingMethod)); 87 | } 88 | 89 | { //! interfaceOrientation 90 | Method replacingMethod = class_getInstanceMethod([self class], @selector(swappedInterfaceOrientation)); 91 | Method replacedMethod = class_getInstanceMethod([UIViewController class], @selector(interfaceOrientation)); 92 | class_addMethod([UIViewController class], @selector(sf_originalInterfaceOrientation), method_getImplementation(replacedMethod), method_getTypeEncoding(replacedMethod)); 93 | class_replaceMethod([UIViewController class], @selector(interfaceOrientation), method_getImplementation(replacingMethod), method_getTypeEncoding(replacingMethod)); 94 | } 95 | 96 | { //! presentModalViewController:animated: 97 | Method replacingMethod = class_getInstanceMethod([self class], @selector(swappedPresentModalViewController:animated:)); 98 | Method replacedMethod = class_getInstanceMethod([UIViewController class], @selector(presentModalViewController:animated:)); 99 | class_addMethod([UIViewController class], @selector(sf_originalPresentModalViewController:animated:), method_getImplementation(replacedMethod), method_getTypeEncoding(replacedMethod)); 100 | class_replaceMethod([UIViewController class], @selector(presentModalViewController:animated:), method_getImplementation(replacingMethod), method_getTypeEncoding(replacingMethod)); 101 | } 102 | 103 | { //! dismissModalViewControllerAnimated: 104 | Method replacingMethod = class_getInstanceMethod([self class], @selector(swappedDismissModalViewControllerAnimated:)); 105 | Method replacedMethod = class_getInstanceMethod([UIViewController class], @selector(dismissModalViewControllerAnimated:)); 106 | class_addMethod([UIViewController class], @selector(sf_originalDismissModalViewControllerAnimated:), method_getImplementation(replacedMethod), method_getTypeEncoding(replacedMethod)); 107 | class_replaceMethod([UIViewController class], @selector(dismissModalViewControllerAnimated:), method_getImplementation(replacingMethod), method_getTypeEncoding(replacingMethod)); 108 | } 109 | }); 110 | } 111 | 112 | - (void)dealloc 113 | { 114 | //! remove association just in case 115 | AH_RELEASE(viewControllers); 116 | AH_SUPER_DEALLOC; 117 | } 118 | 119 | - (void)didReceiveMemoryWarning 120 | { 121 | [super didReceiveMemoryWarning]; 122 | for (UIViewController *viewController in viewControllers) { 123 | [viewController didReceiveMemoryWarning]; 124 | } 125 | } 126 | 127 | #pragma mark - View lifecycle 128 | 129 | - (void)viewDidUnload 130 | { 131 | [super viewDidUnload]; 132 | //! if parent unloaded then its time to ask children to unload their views as parent view no longer retains their views 133 | for (UIViewController *viewController in viewControllers) { 134 | //! this is the ONLY ok way to make child controllers unload their views if they are not retained in other places 135 | [viewController didReceiveMemoryWarning]; 136 | } 137 | } 138 | 139 | - (void)viewWillAppear:(BOOL)animated 140 | { 141 | [super viewWillAppear:animated]; 142 | for (UIViewController *viewController in viewControllers) { 143 | [viewController viewWillAppear:animated]; 144 | } 145 | } 146 | 147 | - (void)viewDidAppear:(BOOL)animated 148 | { 149 | [super viewDidAppear:animated]; 150 | for (UIViewController *viewController in viewControllers) { 151 | [viewController viewDidAppear:animated]; 152 | } 153 | } 154 | 155 | - (void)viewWillDisappear:(BOOL)animated 156 | { 157 | [super viewWillDisappear:animated]; 158 | for (UIViewController *viewController in viewControllers) { 159 | [viewController viewWillDisappear:animated]; 160 | } 161 | } 162 | 163 | - (void)viewDidDisappear:(BOOL)animated 164 | { 165 | [super viewDidDisappear:animated]; 166 | for (UIViewController *viewController in viewControllers) { 167 | [viewController viewDidDisappear:animated]; 168 | } 169 | } 170 | 171 | #pragma mark - Rotation 172 | - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 173 | { 174 | [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 175 | for (UIViewController *viewController in viewControllers) { 176 | [viewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 177 | } 178 | } 179 | 180 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 181 | { 182 | [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 183 | for (UIViewController *viewController in viewControllers) { 184 | [viewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 185 | } 186 | } 187 | 188 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 189 | { 190 | [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 191 | for (UIViewController *viewController in viewControllers) { 192 | [viewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 193 | } 194 | } 195 | 196 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 197 | { 198 | for (UIViewController *viewController in viewControllers) { 199 | if (![viewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]) { 200 | return NO; 201 | } 202 | } 203 | return YES; 204 | } 205 | 206 | #pragma mark - Handling children controller 207 | - (void)setViewControllers:(NSArray *)aViewControllers 208 | { 209 | if (aViewControllers != viewControllers) { 210 | //! remove association from old view controllers 211 | for (UIViewController *viewController in viewControllers) { 212 | objc_setAssociatedObject(viewController, AH_BRIDGE(SFContainerViewControllerParentControllerKey), nil, OBJC_ASSOCIATION_ASSIGN); 213 | } 214 | 215 | AH_RELEASE(viewControllers); 216 | viewControllers = AH_RETAIN([NSArray arrayWithArray:aViewControllers]); 217 | 218 | //! add association in new view controllers 219 | for (UIViewController *viewController in viewControllers) { 220 | objc_setAssociatedObject(viewController, AH_BRIDGE(SFContainerViewControllerParentControllerKey), self, OBJC_ASSOCIATION_ASSIGN); 221 | } 222 | } 223 | } 224 | 225 | #pragma mark - UIViewController additional methods 226 | - (UINavigationController*)swappedNavigationController 227 | { 228 | UIViewController *parentController = objc_getAssociatedObject(self, AH_BRIDGE(SFContainerViewControllerParentControllerKey)); 229 | if (parentController) { 230 | return parentController.navigationController; 231 | } else { 232 | return [self performSelector:@selector(sf_originalNavigationController)]; 233 | } 234 | } 235 | 236 | - (UIViewController*)swappedParentViewController 237 | { 238 | UIViewController *parentController = objc_getAssociatedObject(self, AH_BRIDGE(SFContainerViewControllerParentControllerKey)); 239 | if (parentController) { 240 | return parentController; 241 | } else { 242 | return [self performSelector:@selector(sf_originalParentViewController)]; 243 | } 244 | } 245 | 246 | - (UIInterfaceOrientation)swappedInterfaceOrientation 247 | { 248 | UIViewController *parentController = objc_getAssociatedObject(self, AH_BRIDGE(SFContainerViewControllerParentControllerKey)); 249 | if (parentController) { 250 | return parentController.interfaceOrientation; 251 | } else { 252 | return (UIInterfaceOrientation)[self performSelector:@selector(sf_originalInterfaceOrientation)]; 253 | } 254 | } 255 | 256 | - (void)swappedPresentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated 257 | { 258 | UIViewController *parentController = objc_getAssociatedObject(self, AH_BRIDGE(SFContainerViewControllerParentControllerKey)); 259 | if (parentController) { 260 | [parentController presentViewController:modalViewController animated:animated completion:nil]; 261 | objc_setAssociatedObject(modalViewController, AH_BRIDGE(SFContainerViewControllerParentControllerKey), self, OBJC_ASSOCIATION_ASSIGN); 262 | } else { 263 | objc_msgSend(self, NSSelectorFromString(@"sf_originalPresentModalViewController:animated:"), modalViewController, animated); 264 | } 265 | } 266 | 267 | - (void)swappedDismissModalViewControllerAnimated:(BOOL)animated 268 | { 269 | UIViewController *parentController = objc_getAssociatedObject(self, AH_BRIDGE(SFContainerViewControllerParentControllerKey)); 270 | if (parentController) { 271 | UIViewController *modalViewController = AH_RETAIN(self.presentedViewController); 272 | [parentController dismissViewControllerAnimated:animated completion:nil]; 273 | objc_setAssociatedObject(modalViewController, AH_BRIDGE(SFContainerViewControllerParentControllerKey), nil, OBJC_ASSOCIATION_ASSIGN); 274 | } else { 275 | objc_msgSend(self, NSSelectorFromString(@"sf_originalDismissModalViewControllerAnimated:"), animated); 276 | } 277 | } 278 | 279 | @end 280 | -------------------------------------------------------------------------------- /Sample Projects/SFContainerViewController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B13466014F7A3530029CB60 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13465F14F7A3530029CB60 /* UIKit.framework */; }; 11 | 1B13466214F7A3530029CB60 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13466114F7A3530029CB60 /* Foundation.framework */; }; 12 | 1B13466414F7A3530029CB60 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13466314F7A3530029CB60 /* CoreGraphics.framework */; }; 13 | 1B13466A14F7A3530029CB60 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1B13466814F7A3530029CB60 /* InfoPlist.strings */; }; 14 | 1B13466C14F7A3530029CB60 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13466B14F7A3530029CB60 /* main.m */; }; 15 | 1B13467014F7A3530029CB60 /* SFAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */; }; 16 | 1B13468514F7C13B0029CB60 /* SFContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */; }; 17 | 1B13468814F7C19C0029CB60 /* SFRandomContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */; }; 18 | 1B13468B14F7C6A30029CB60 /* SFRandomContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */; }; 19 | 1B13468E14F7C87E0029CB60 /* SFLoggingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SFContainerViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 1B13465F14F7A3530029CB60 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 25 | 1B13466114F7A3530029CB60 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 1B13466314F7A3530029CB60 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 1B13466714F7A3530029CB60 /* SFContainerViewController-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SFContainerViewController-Info.plist"; sourceTree = ""; }; 28 | 1B13466914F7A3530029CB60 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 1B13466B14F7A3530029CB60 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 1B13466D14F7A3530029CB60 /* SFContainerViewController-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SFContainerViewController-Prefix.pch"; sourceTree = ""; }; 31 | 1B13466E14F7A3530029CB60 /* SFAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SFAppDelegate.h; sourceTree = ""; }; 32 | 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SFAppDelegate.m; sourceTree = ""; }; 33 | 1B13468314F7C13B0029CB60 /* SFContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFContainerViewController.h; sourceTree = ""; }; 34 | 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFContainerViewController.m; sourceTree = ""; }; 35 | 1B13468614F7C19C0029CB60 /* SFRandomContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFRandomContainerViewController.h; sourceTree = ""; }; 36 | 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFRandomContainerViewController.m; sourceTree = ""; }; 37 | 1B13468914F7C6A30029CB60 /* SFRandomContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFRandomContainerView.h; sourceTree = ""; }; 38 | 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFRandomContainerView.m; sourceTree = ""; }; 39 | 1B13468C14F7C87E0029CB60 /* SFLoggingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SFLoggingViewController.h; path = SFContainerViewController/SFLoggingViewController.h; sourceTree = SOURCE_ROOT; }; 40 | 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFLoggingViewController.m; path = SFContainerViewController/SFLoggingViewController.m; sourceTree = SOURCE_ROOT; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 1B13465814F7A3530029CB60 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 1B13466014F7A3530029CB60 /* UIKit.framework in Frameworks */, 49 | 1B13466214F7A3530029CB60 /* Foundation.framework in Frameworks */, 50 | 1B13466414F7A3530029CB60 /* CoreGraphics.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 1B13465014F7A3530029CB60 = { 58 | isa = PBXGroup; 59 | children = ( 60 | 1B13466514F7A3530029CB60 /* SFContainerViewController */, 61 | 1B13465E14F7A3530029CB60 /* Frameworks */, 62 | 1B13465C14F7A3530029CB60 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 1B13465C14F7A3530029CB60 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 1B13465E14F7A3530029CB60 /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 1B13465F14F7A3530029CB60 /* UIKit.framework */, 78 | 1B13466114F7A3530029CB60 /* Foundation.framework */, 79 | 1B13466314F7A3530029CB60 /* CoreGraphics.framework */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | 1B13466514F7A3530029CB60 /* SFContainerViewController */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 1B13468214F7C13B0029CB60 /* ContainerViewController */, 88 | 1B13468C14F7C87E0029CB60 /* SFLoggingViewController.h */, 89 | 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */, 90 | 1B13466E14F7A3530029CB60 /* SFAppDelegate.h */, 91 | 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */, 92 | 1B13466614F7A3530029CB60 /* Supporting Files */, 93 | 1B13468614F7C19C0029CB60 /* SFRandomContainerViewController.h */, 94 | 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */, 95 | 1B13468914F7C6A30029CB60 /* SFRandomContainerView.h */, 96 | 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */, 97 | ); 98 | path = SFContainerViewController; 99 | sourceTree = ""; 100 | }; 101 | 1B13466614F7A3530029CB60 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 1B13466714F7A3530029CB60 /* SFContainerViewController-Info.plist */, 105 | 1B13466814F7A3530029CB60 /* InfoPlist.strings */, 106 | 1B13466B14F7A3530029CB60 /* main.m */, 107 | 1B13466D14F7A3530029CB60 /* SFContainerViewController-Prefix.pch */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 1B13468214F7C13B0029CB60 /* ContainerViewController */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 1B13468314F7C13B0029CB60 /* SFContainerViewController.h */, 116 | 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */, 117 | ); 118 | name = ContainerViewController; 119 | path = ../../ContainerViewController; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 1B13465A14F7A3530029CB60 /* SFContainerViewController */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 1B13467314F7A3530029CB60 /* Build configuration list for PBXNativeTarget "SFContainerViewController" */; 128 | buildPhases = ( 129 | 1B13465714F7A3530029CB60 /* Sources */, 130 | 1B13465814F7A3530029CB60 /* Frameworks */, 131 | 1B13465914F7A3530029CB60 /* Resources */, 132 | ); 133 | buildRules = ( 134 | ); 135 | dependencies = ( 136 | ); 137 | name = SFContainerViewController; 138 | productName = SFContainerViewController; 139 | productReference = 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */; 140 | productType = "com.apple.product-type.application"; 141 | }; 142 | /* End PBXNativeTarget section */ 143 | 144 | /* Begin PBXProject section */ 145 | 1B13465214F7A3530029CB60 /* Project object */ = { 146 | isa = PBXProject; 147 | attributes = { 148 | LastUpgradeCheck = 0420; 149 | }; 150 | buildConfigurationList = 1B13465514F7A3530029CB60 /* Build configuration list for PBXProject "SFContainerViewController" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | ); 157 | mainGroup = 1B13465014F7A3530029CB60; 158 | productRefGroup = 1B13465C14F7A3530029CB60 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 1B13465A14F7A3530029CB60 /* SFContainerViewController */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | 1B13465914F7A3530029CB60 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 1B13466A14F7A3530029CB60 /* InfoPlist.strings in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | 1B13465714F7A3530029CB60 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | 1B13466C14F7A3530029CB60 /* main.m in Sources */, 184 | 1B13467014F7A3530029CB60 /* SFAppDelegate.m in Sources */, 185 | 1B13468514F7C13B0029CB60 /* SFContainerViewController.m in Sources */, 186 | 1B13468814F7C19C0029CB60 /* SFRandomContainerViewController.m in Sources */, 187 | 1B13468B14F7C6A30029CB60 /* SFRandomContainerView.m in Sources */, 188 | 1B13468E14F7C87E0029CB60 /* SFLoggingViewController.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin PBXVariantGroup section */ 195 | 1B13466814F7A3530029CB60 /* InfoPlist.strings */ = { 196 | isa = PBXVariantGroup; 197 | children = ( 198 | 1B13466914F7A3530029CB60 /* en */, 199 | ); 200 | name = InfoPlist.strings; 201 | sourceTree = ""; 202 | }; 203 | /* End PBXVariantGroup section */ 204 | 205 | /* Begin XCBuildConfiguration section */ 206 | 1B13467114F7A3530029CB60 /* Debug */ = { 207 | isa = XCBuildConfiguration; 208 | buildSettings = { 209 | ALWAYS_SEARCH_USER_PATHS = NO; 210 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 221 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 222 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 223 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 226 | SDKROOT = iphoneos; 227 | TARGETED_DEVICE_FAMILY = "1,2"; 228 | }; 229 | name = Debug; 230 | }; 231 | 1B13467214F7A3530029CB60 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = YES; 238 | GCC_C_LANGUAGE_STANDARD = gnu99; 239 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 240 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 241 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 244 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 245 | SDKROOT = iphoneos; 246 | TARGETED_DEVICE_FAMILY = "1,2"; 247 | VALIDATE_PRODUCT = YES; 248 | }; 249 | name = Release; 250 | }; 251 | 1B13467414F7A3530029CB60 /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 255 | GCC_PREFIX_HEADER = "SFContainerViewController/SFContainerViewController-Prefix.pch"; 256 | INFOPLIST_FILE = "SFContainerViewController/SFContainerViewController-Info.plist"; 257 | PRODUCT_NAME = "$(TARGET_NAME)"; 258 | WRAPPER_EXTENSION = app; 259 | }; 260 | name = Debug; 261 | }; 262 | 1B13467514F7A3530029CB60 /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 266 | GCC_PREFIX_HEADER = "SFContainerViewController/SFContainerViewController-Prefix.pch"; 267 | INFOPLIST_FILE = "SFContainerViewController/SFContainerViewController-Info.plist"; 268 | PRODUCT_NAME = "$(TARGET_NAME)"; 269 | WRAPPER_EXTENSION = app; 270 | }; 271 | name = Release; 272 | }; 273 | /* End XCBuildConfiguration section */ 274 | 275 | /* Begin XCConfigurationList section */ 276 | 1B13465514F7A3530029CB60 /* Build configuration list for PBXProject "SFContainerViewController" */ = { 277 | isa = XCConfigurationList; 278 | buildConfigurations = ( 279 | 1B13467114F7A3530029CB60 /* Debug */, 280 | 1B13467214F7A3530029CB60 /* Release */, 281 | ); 282 | defaultConfigurationIsVisible = 0; 283 | defaultConfigurationName = Release; 284 | }; 285 | 1B13467314F7A3530029CB60 /* Build configuration list for PBXNativeTarget "SFContainerViewController" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 1B13467414F7A3530029CB60 /* Debug */, 289 | 1B13467514F7A3530029CB60 /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | /* End XCConfigurationList section */ 295 | }; 296 | rootObject = 1B13465214F7A3530029CB60 /* Project object */; 297 | } 298 | -------------------------------------------------------------------------------- /Sample Projects ARC/SFContainerViewController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B13466014F7A3530029CB60 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13465F14F7A3530029CB60 /* UIKit.framework */; }; 11 | 1B13466214F7A3530029CB60 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13466114F7A3530029CB60 /* Foundation.framework */; }; 12 | 1B13466414F7A3530029CB60 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13466314F7A3530029CB60 /* CoreGraphics.framework */; }; 13 | 1B13466A14F7A3530029CB60 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1B13466814F7A3530029CB60 /* InfoPlist.strings */; }; 14 | 1B13466C14F7A3530029CB60 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13466B14F7A3530029CB60 /* main.m */; }; 15 | 1B13467014F7A3530029CB60 /* SFAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */; }; 16 | 1B13468514F7C13B0029CB60 /* SFContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 17 | 1B13468814F7C19C0029CB60 /* SFRandomContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */; }; 18 | 1B13468B14F7C6A30029CB60 /* SFRandomContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */; }; 19 | 1B13468E14F7C87E0029CB60 /* SFLoggingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SFContainerViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 1B13465F14F7A3530029CB60 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 25 | 1B13466114F7A3530029CB60 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 1B13466314F7A3530029CB60 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 1B13466714F7A3530029CB60 /* SFContainerViewController-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SFContainerViewController-Info.plist"; sourceTree = ""; }; 28 | 1B13466914F7A3530029CB60 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 1B13466B14F7A3530029CB60 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 1B13466D14F7A3530029CB60 /* SFContainerViewController-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SFContainerViewController-Prefix.pch"; sourceTree = ""; }; 31 | 1B13466E14F7A3530029CB60 /* SFAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SFAppDelegate.h; sourceTree = ""; }; 32 | 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SFAppDelegate.m; sourceTree = ""; }; 33 | 1B13468314F7C13B0029CB60 /* SFContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFContainerViewController.h; sourceTree = ""; }; 34 | 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFContainerViewController.m; sourceTree = ""; }; 35 | 1B13468614F7C19C0029CB60 /* SFRandomContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFRandomContainerViewController.h; sourceTree = ""; }; 36 | 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFRandomContainerViewController.m; sourceTree = ""; }; 37 | 1B13468914F7C6A30029CB60 /* SFRandomContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFRandomContainerView.h; sourceTree = ""; }; 38 | 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFRandomContainerView.m; sourceTree = ""; }; 39 | 1B13468C14F7C87E0029CB60 /* SFLoggingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SFLoggingViewController.h; path = SFContainerViewController/SFLoggingViewController.h; sourceTree = SOURCE_ROOT; }; 40 | 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFLoggingViewController.m; path = SFContainerViewController/SFLoggingViewController.m; sourceTree = SOURCE_ROOT; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 1B13465814F7A3530029CB60 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 1B13466014F7A3530029CB60 /* UIKit.framework in Frameworks */, 49 | 1B13466214F7A3530029CB60 /* Foundation.framework in Frameworks */, 50 | 1B13466414F7A3530029CB60 /* CoreGraphics.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 1B13465014F7A3530029CB60 = { 58 | isa = PBXGroup; 59 | children = ( 60 | 1B13466514F7A3530029CB60 /* SFContainerViewController */, 61 | 1B13465E14F7A3530029CB60 /* Frameworks */, 62 | 1B13465C14F7A3530029CB60 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 1B13465C14F7A3530029CB60 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 1B13465E14F7A3530029CB60 /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 1B13465F14F7A3530029CB60 /* UIKit.framework */, 78 | 1B13466114F7A3530029CB60 /* Foundation.framework */, 79 | 1B13466314F7A3530029CB60 /* CoreGraphics.framework */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | 1B13466514F7A3530029CB60 /* SFContainerViewController */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 1B13468214F7C13B0029CB60 /* ContainerViewController */, 88 | 1B13468C14F7C87E0029CB60 /* SFLoggingViewController.h */, 89 | 1B13468D14F7C87E0029CB60 /* SFLoggingViewController.m */, 90 | 1B13466E14F7A3530029CB60 /* SFAppDelegate.h */, 91 | 1B13466F14F7A3530029CB60 /* SFAppDelegate.m */, 92 | 1B13466614F7A3530029CB60 /* Supporting Files */, 93 | 1B13468614F7C19C0029CB60 /* SFRandomContainerViewController.h */, 94 | 1B13468714F7C19C0029CB60 /* SFRandomContainerViewController.m */, 95 | 1B13468914F7C6A30029CB60 /* SFRandomContainerView.h */, 96 | 1B13468A14F7C6A30029CB60 /* SFRandomContainerView.m */, 97 | ); 98 | path = SFContainerViewController; 99 | sourceTree = ""; 100 | }; 101 | 1B13466614F7A3530029CB60 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 1B13466714F7A3530029CB60 /* SFContainerViewController-Info.plist */, 105 | 1B13466814F7A3530029CB60 /* InfoPlist.strings */, 106 | 1B13466B14F7A3530029CB60 /* main.m */, 107 | 1B13466D14F7A3530029CB60 /* SFContainerViewController-Prefix.pch */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 1B13468214F7C13B0029CB60 /* ContainerViewController */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 1B13468314F7C13B0029CB60 /* SFContainerViewController.h */, 116 | 1B13468414F7C13B0029CB60 /* SFContainerViewController.m */, 117 | ); 118 | name = ContainerViewController; 119 | path = ../../ContainerViewController; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 1B13465A14F7A3530029CB60 /* SFContainerViewController */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 1B13467314F7A3530029CB60 /* Build configuration list for PBXNativeTarget "SFContainerViewController" */; 128 | buildPhases = ( 129 | 1B13465714F7A3530029CB60 /* Sources */, 130 | 1B13465814F7A3530029CB60 /* Frameworks */, 131 | 1B13465914F7A3530029CB60 /* Resources */, 132 | ); 133 | buildRules = ( 134 | ); 135 | dependencies = ( 136 | ); 137 | name = SFContainerViewController; 138 | productName = SFContainerViewController; 139 | productReference = 1B13465B14F7A3530029CB60 /* SFContainerViewController.app */; 140 | productType = "com.apple.product-type.application"; 141 | }; 142 | /* End PBXNativeTarget section */ 143 | 144 | /* Begin PBXProject section */ 145 | 1B13465214F7A3530029CB60 /* Project object */ = { 146 | isa = PBXProject; 147 | attributes = { 148 | LastUpgradeCheck = 0420; 149 | }; 150 | buildConfigurationList = 1B13465514F7A3530029CB60 /* Build configuration list for PBXProject "SFContainerViewController" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | ); 157 | mainGroup = 1B13465014F7A3530029CB60; 158 | productRefGroup = 1B13465C14F7A3530029CB60 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 1B13465A14F7A3530029CB60 /* SFContainerViewController */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | 1B13465914F7A3530029CB60 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 1B13466A14F7A3530029CB60 /* InfoPlist.strings in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | 1B13465714F7A3530029CB60 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | 1B13466C14F7A3530029CB60 /* main.m in Sources */, 184 | 1B13467014F7A3530029CB60 /* SFAppDelegate.m in Sources */, 185 | 1B13468514F7C13B0029CB60 /* SFContainerViewController.m in Sources */, 186 | 1B13468814F7C19C0029CB60 /* SFRandomContainerViewController.m in Sources */, 187 | 1B13468B14F7C6A30029CB60 /* SFRandomContainerView.m in Sources */, 188 | 1B13468E14F7C87E0029CB60 /* SFLoggingViewController.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin PBXVariantGroup section */ 195 | 1B13466814F7A3530029CB60 /* InfoPlist.strings */ = { 196 | isa = PBXVariantGroup; 197 | children = ( 198 | 1B13466914F7A3530029CB60 /* en */, 199 | ); 200 | name = InfoPlist.strings; 201 | sourceTree = ""; 202 | }; 203 | /* End PBXVariantGroup section */ 204 | 205 | /* Begin XCBuildConfiguration section */ 206 | 1B13467114F7A3530029CB60 /* Debug */ = { 207 | isa = XCBuildConfiguration; 208 | buildSettings = { 209 | ALWAYS_SEARCH_USER_PATHS = NO; 210 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 221 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 222 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 223 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 226 | SDKROOT = iphoneos; 227 | TARGETED_DEVICE_FAMILY = "1,2"; 228 | }; 229 | name = Debug; 230 | }; 231 | 1B13467214F7A3530029CB60 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = YES; 238 | GCC_C_LANGUAGE_STANDARD = gnu99; 239 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 240 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 241 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 244 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 245 | SDKROOT = iphoneos; 246 | TARGETED_DEVICE_FAMILY = "1,2"; 247 | VALIDATE_PRODUCT = YES; 248 | }; 249 | name = Release; 250 | }; 251 | 1B13467414F7A3530029CB60 /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 256 | GCC_PREFIX_HEADER = "SFContainerViewController/SFContainerViewController-Prefix.pch"; 257 | INFOPLIST_FILE = "SFContainerViewController/SFContainerViewController-Info.plist"; 258 | PRODUCT_NAME = "$(TARGET_NAME)"; 259 | WRAPPER_EXTENSION = app; 260 | }; 261 | name = Debug; 262 | }; 263 | 1B13467514F7A3530029CB60 /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 268 | GCC_PREFIX_HEADER = "SFContainerViewController/SFContainerViewController-Prefix.pch"; 269 | INFOPLIST_FILE = "SFContainerViewController/SFContainerViewController-Info.plist"; 270 | PRODUCT_NAME = "$(TARGET_NAME)"; 271 | WRAPPER_EXTENSION = app; 272 | }; 273 | name = Release; 274 | }; 275 | /* End XCBuildConfiguration section */ 276 | 277 | /* Begin XCConfigurationList section */ 278 | 1B13465514F7A3530029CB60 /* Build configuration list for PBXProject "SFContainerViewController" */ = { 279 | isa = XCConfigurationList; 280 | buildConfigurations = ( 281 | 1B13467114F7A3530029CB60 /* Debug */, 282 | 1B13467214F7A3530029CB60 /* Release */, 283 | ); 284 | defaultConfigurationIsVisible = 0; 285 | defaultConfigurationName = Release; 286 | }; 287 | 1B13467314F7A3530029CB60 /* Build configuration list for PBXNativeTarget "SFContainerViewController" */ = { 288 | isa = XCConfigurationList; 289 | buildConfigurations = ( 290 | 1B13467414F7A3530029CB60 /* Debug */, 291 | 1B13467514F7A3530029CB60 /* Release */, 292 | ); 293 | defaultConfigurationIsVisible = 0; 294 | defaultConfigurationName = Release; 295 | }; 296 | /* End XCConfigurationList section */ 297 | }; 298 | rootObject = 1B13465214F7A3530029CB60 /* Project object */; 299 | } 300 | --------------------------------------------------------------------------------