├── README Images └── PopinController.gif ├── PBControllerDemo.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── Classes ├── PBPopinSegue.h ├── PBModalPopinSegue.h ├── PBPopinSegue.m ├── PBModalPopinSegue.m ├── UIViewController+PopinController.h ├── UIViewController+PopinController.m ├── PBPopinContainerViewController.h ├── PBPopinController.h ├── PBPopinController.m └── PBPopinContainerViewController.m ├── PBControllerDemo ├── AppDelegate.h ├── main.m ├── PictureViewController.h ├── DatePickerViewController.h ├── CountryPickerViewController.h ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── TableViewController.h ├── DatePickerViewController.m ├── Info.plist ├── PictureViewController.m ├── AppDelegate.m ├── CountryPickerViewController.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard └── TableViewController.m ├── CHANGES ├── .cocoadocs.yml ├── .gitignore ├── PBPopinController.podspec ├── PBControllerDemoTests ├── Info.plist └── PBControllerDemoTests.m ├── LICENSE └── README.md /README Images/PopinController.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pronebird/PBPopinController/HEAD/README Images/PopinController.gif -------------------------------------------------------------------------------- /PBControllerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Classes/PBPopinSegue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinSegue.h 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Segue class that presents view controllers in pop-in view. 12 | */ 13 | @interface PBPopinSegue : UIStoryboardSegue 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/PBModalPopinSegue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PBModalPopinSegue.h 3 | // 4 | // Created by pronebird on 3/31/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Segue class that presents view controllers in modal pop-in view. 12 | */ 13 | @interface PBModalPopinSegue : UIStoryboardSegue 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PBControllerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | = 0.3.0 (2015-03-31) 2 | 3 | * Add modal popin presentation 4 | * Add modal popin segue 5 | * Add tap-to-dismiss recognizer on backdrop 6 | * Animate frame changes when replacing content controller 7 | * Swizzle prepareForSegue to capture sender view (needed for scroll) 8 | * Automatically scroll to sender view in scroll views 9 | * Adjust scroll view content insets to accomodate pop-in controller 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PBControllerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PBControllerDemo/PictureViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PictureViewController.h 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 3/31/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PictureViewController : UIViewController 12 | 13 | @property (copy) void(^didFinishPickingPhoto)(UIImage *image); 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /.cocoadocs.yml: -------------------------------------------------------------------------------- 1 | highlight-font: '"GT Walsheim", "gt_walsheim_regular", "Avant Garde Gothic ITCW01Dm", "Avant Garde", "Helvetica Neue", "Arial" ' 2 | body: '"Helvetica Neue", "Arial", san-serif' 3 | code: '"Monaco", "Menlo", "Consolas", "Courier New", monospace' 4 | 5 | highlight-color: "#2BCDED" 6 | highlight-dark-color: "#1D4B99" 7 | darker-color: "#666666" 8 | darker-dark-color: "#444444" 9 | background-color: "#F2F2F2" 10 | alt-link-color: "#036E0A" 11 | warning-color: "#B84421" 12 | 13 | -------------------------------------------------------------------------------- /PBControllerDemo/DatePickerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DatePickerViewController.h 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DatePickerViewController : UIViewController 12 | 13 | @property (weak) IBOutlet UIDatePicker *datePicker; 14 | 15 | @property (nonatomic) NSDate *currentDate; 16 | 17 | @property (copy) void(^didChangeDate)(NSDate *date); 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PBControllerDemo/CountryPickerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CountryPickerViewController.h 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CountryPickerViewController : UIViewController 12 | 13 | @property (weak) IBOutlet UIPickerView *pickerView; 14 | 15 | @property NSString *initialCountry; 16 | 17 | @property (copy) void(^didSelectCountry)(NSString *country); 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /PBPopinController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'PBPopinController' 3 | s.version = '0.4.1' 4 | s.license = 'MIT' 5 | s.summary = 'Custom container controller with keyboard-like presentation.' 6 | s.homepage = 'https://github.com/pronebird/PBPopinController' 7 | s.authors = { 8 | 'Andrej Mihajlov' => 'and@codeispoetry.ru' 9 | } 10 | s.source = { 11 | :git => 'https://github.com/pronebird/PBPopinController.git', 12 | :tag => s.version.to_s 13 | } 14 | s.source_files = 'Classes/*.{h,m}' 15 | s.requires_arc = true 16 | s.ios.deployment_target = '8.0' 17 | end 18 | -------------------------------------------------------------------------------- /Classes/PBPopinSegue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinSegue.m 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import "PBPopinSegue.h" 9 | #import "PBPopinController.h" 10 | 11 | @implementation PBPopinSegue 12 | 13 | - (void)perform { 14 | [[PBPopinController sharedPopinController] presentWithContentViewController:self.destinationViewController 15 | fromViewController:self.sourceViewController 16 | animated:YES 17 | completion:nil]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/PBModalPopinSegue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PBModalPopinSegue.m 3 | // 4 | // Created by pronebird on 3/31/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import "PBModalPopinSegue.h" 9 | #import "PBPopinController.h" 10 | 11 | @implementation PBModalPopinSegue 12 | 13 | - (void)perform { 14 | [[PBPopinController sharedPopinController] presentModalWithContentViewController:self.destinationViewController 15 | fromViewController:self.sourceViewController 16 | animated:YES 17 | completion:nil]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PBControllerDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PBControllerDemo/TableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.h 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TableViewController : UITableViewController 12 | 13 | @property (weak) IBOutlet UILabel* dateLabel; 14 | @property (weak) IBOutlet UILabel* countryLabel; 15 | @property (weak) IBOutlet UITextField* textField; 16 | @property (weak) IBOutlet UIToolbar* keyboardAccessory; 17 | @property (strong) IBOutlet UIBarButtonItem* todayAccessoryItem; 18 | @property (weak) IBOutlet UIToolbar* popinAccessory; 19 | @property (weak) IBOutlet UIImageView *photoImageView; 20 | 21 | @property NSDate* selectedDate; 22 | @property NSString* selectedCountry; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/UIViewController+PopinController.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+PopinController.h 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class PBPopinController; 11 | 12 | @interface UIViewController (PopinController) 13 | 14 | /** 15 | * @abstract An instance of popin controller presenting this view controller. 16 | * @discussion This property is nil if controller is not presented. 17 | */ 18 | @property (readonly, nonatomic) PBPopinController* popinController; 19 | 20 | /** 21 | * @abstract Get or set accessory view for popin. 22 | * @discussion Accessory view is placed above content controller. It works the same way as inputAccessoryView on text fields. 23 | */ 24 | @property (nonatomic) UIView* popinAccessoryView; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /PBControllerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ru.codeispoetry.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PBControllerDemoTests/PBControllerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PBControllerDemoTests.m 3 | // PBControllerDemoTests 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface PBControllerDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PBControllerDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/UIViewController+PopinController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+PopinController.m 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import "UIViewController+PopinController.h" 9 | #import "PBPopinController.h" 10 | #import "PBPopinSegue.h" 11 | 12 | #import 13 | 14 | const void* PopinControllerKey = &PopinControllerKey; 15 | const void* PopinAccessoryViewKey = &PopinAccessoryViewKey; 16 | 17 | @implementation UIViewController (PopinController) 18 | 19 | - (PBPopinController*)popinController { 20 | return objc_getAssociatedObject(self, PopinControllerKey); 21 | } 22 | 23 | - (void)setPopinController:(PBPopinController*)popinController { 24 | objc_setAssociatedObject(self, PopinControllerKey, popinController, OBJC_ASSOCIATION_RETAIN); 25 | } 26 | 27 | - (UIView*)popinAccessoryView { 28 | return objc_getAssociatedObject(self, PopinAccessoryViewKey); 29 | } 30 | 31 | - (void)setPopinAccessoryView:(UIView *)popinAccessoryView { 32 | objc_setAssociatedObject(self, PopinAccessoryViewKey, popinAccessoryView, OBJC_ASSOCIATION_RETAIN); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Andrej Mihajlov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /PBControllerDemo/DatePickerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DatePickerViewController.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import "DatePickerViewController.h" 10 | 11 | @implementation DatePickerViewController 12 | 13 | - (void)viewDidLoad { 14 | [super viewDidLoad]; 15 | 16 | if(self.currentDate) { 17 | self.datePicker.date = self.currentDate; 18 | } 19 | 20 | // setup preferred size for controller 21 | self.preferredContentSize = self.datePicker.intrinsicContentSize; 22 | } 23 | 24 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { 25 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 26 | 27 | self.preferredContentSize = self.datePicker.intrinsicContentSize; 28 | } 29 | 30 | - (void)setCurrentDate:(NSDate *)currentDate { 31 | if(![_currentDate isEqualToDate:currentDate]) { 32 | _currentDate = currentDate; 33 | [self.datePicker setDate:currentDate animated:YES]; 34 | } 35 | } 36 | 37 | - (IBAction)datePickerDidChangeValue:(id)sender { 38 | self.currentDate = self.datePicker.date; 39 | 40 | if(self.didChangeDate) { 41 | self.didChangeDate(self.currentDate); 42 | } 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PBControllerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ru.codeispoetry.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PBControllerDemo/PictureViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PictureViewController.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 3/31/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import "PictureViewController.h" 10 | #import "PBPopinController.h" 11 | #import "UIViewController+PopinController.h" 12 | 13 | @interface PictureViewController () 14 | 15 | @property UIImagePickerController *imagePicker; 16 | 17 | @end 18 | 19 | @implementation PictureViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | self.imagePicker = [[UIImagePickerController alloc] init]; 25 | self.imagePicker.delegate = self; 26 | self.imagePicker.view.translatesAutoresizingMaskIntoConstraints = NO; 27 | 28 | [self addChildViewController:self.imagePicker]; 29 | [self.view addSubview:self.imagePicker.view]; 30 | [self.imagePicker didMoveToParentViewController:self]; 31 | 32 | NSDictionary *viewsDictionary = @{ @"imagePicker": self.imagePicker.view }; 33 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[imagePicker]|" options:0 metrics:nil views:viewsDictionary]]; 34 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[imagePicker]|" options:0 metrics:nil views:viewsDictionary]]; 35 | } 36 | 37 | #pragma mark - UIImagePickerControllerDelegate 38 | 39 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 40 | if(self.didFinishPickingPhoto) { 41 | UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; 42 | 43 | self.didFinishPickingPhoto(image); 44 | } 45 | [self.popinController dismissAnimated:YES completion:nil]; 46 | } 47 | 48 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 49 | [self.popinController dismissAnimated:YES completion:nil]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PBControllerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PBControllerDemo/CountryPickerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CountryPickerViewController.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import "CountryPickerViewController.h" 10 | 11 | @interface CountryPickerViewController() 12 | 13 | @property NSArray *countryList; 14 | 15 | @end 16 | 17 | @implementation CountryPickerViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | NSString *identifier = [[NSLocale preferredLanguages] firstObject]; 23 | NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:identifier]; 24 | NSMutableArray *countryList = [NSMutableArray new]; 25 | 26 | for(NSString *countryCode in [NSLocale ISOCountryCodes]) { 27 | NSString *displayNameString = [locale displayNameForKey:NSLocaleCountryCode value:countryCode]; 28 | [countryList addObject:displayNameString]; 29 | } 30 | 31 | self.countryList = [countryList sortedArrayUsingSelector:@selector(localizedCompare:)]; 32 | 33 | if(self.initialCountry) { 34 | NSUInteger index = [self.countryList indexOfObject:self.initialCountry]; 35 | if(index != NSNotFound) { 36 | [self.pickerView selectRow:index inComponent:0 animated:NO]; 37 | } 38 | } 39 | 40 | // setup preferred size for controller 41 | self.preferredContentSize = self.pickerView.intrinsicContentSize; 42 | } 43 | 44 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { 45 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 46 | 47 | self.preferredContentSize = self.pickerView.intrinsicContentSize; 48 | } 49 | 50 | #pragma mark - UIPickerViewDataSource 51 | 52 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 53 | return 1; 54 | } 55 | 56 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 57 | return self.countryList.count; 58 | } 59 | 60 | #pragma marl - UIPickerViewDelegate 61 | 62 | - (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 63 | return self.countryList[row]; 64 | } 65 | 66 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 67 | if(self.didSelectCountry) { 68 | self.didSelectCountry(self.countryList[row]); 69 | } 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Classes/PBPopinContainerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinContainerViewController.h 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface PBPopinContainerViewController : UIViewController 11 | 12 | /** 13 | * Current content controller. 14 | */ 15 | @property (nonatomic, readonly) UIViewController* contentViewController; 16 | 17 | /** 18 | * Source controller. 19 | * Used to redirect status bar appearance events. 20 | */ 21 | @property (weak, nonatomic) UIViewController *sourceViewController; 22 | 23 | /** 24 | * Backdrop view. 25 | */ 26 | @property (nonatomic, readonly) UIView *backdropView; 27 | 28 | /** 29 | * Whether view controller should show a backdrop view. 30 | */ 31 | @property (nonatomic) BOOL showsBackdrop; 32 | 33 | /** 34 | * Designated initializer. 35 | * 36 | * @param contentViewController an instance of content view controller or nil 37 | * 38 | * @return an instance of PopinContainerViewController 39 | */ 40 | - (instancetype)initWithContentViewController:(UIViewController*)contentViewController; 41 | 42 | /** 43 | * Animate backdrop. 44 | * 45 | * @param showsBackdrop fade in or out 46 | * @param animated use animations or not 47 | */ 48 | - (void)setShowsBackdrop:(BOOL)showsBackdrop animated:(BOOL)animated; 49 | 50 | /** 51 | * Set content view controller. 52 | * 53 | * @param contentViewController an instance of content view controller 54 | * @param animated use animations or not 55 | * @param alongsideAnimation a block that will be called within animation block 56 | * @param completion a handler block called in the end of transition 57 | */ 58 | - (void)setContentViewController:(UIViewController *)contentViewController 59 | animated:(BOOL)animated 60 | alongsideAnimation:(void(^)(void))alongsideAnimation 61 | completion:(void(^)(void))completion; 62 | 63 | /** 64 | * Frame of content view controller when presented. 65 | * 66 | * @param controller a content view controller 67 | * 68 | * @return CGRect 69 | */ 70 | - (CGRect)finalFrameForTransitionView:(UIViewController*)controller; 71 | 72 | /** 73 | * Frame of content view controller when offscreen. 74 | * 75 | * @param controller a content view controller 76 | * 77 | * @return CGRect 78 | */ 79 | - (CGRect)initialFrameForTransitionView:(UIViewController*)controller; 80 | 81 | /** 82 | * Animation duration used for transition. 83 | * 84 | * @return NSTimeInterval 85 | */ 86 | - (NSTimeInterval)transitionDuration; 87 | 88 | /** 89 | * Animation curve used for transition. 90 | * 91 | * @return UIViewAnimationCurve 92 | */ 93 | - (UIViewAnimationCurve)transitionAnimationCurve; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /PBControllerDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Classes/PBPopinController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinController.h 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "UIViewController+PopinController.h" 10 | 11 | /** 12 | * A notification sent before controller appears. 13 | */ 14 | extern NSString * const PBPopinControllerWillAppearNotification; 15 | 16 | /** 17 | * A notification sent after controller appears. 18 | */ 19 | extern NSString * const PBPopinControllerDidAppearNotification; 20 | 21 | /** 22 | * A notification sent before controller disappears. 23 | */ 24 | extern NSString * const PBPopinControllerWillDisappearNotification; 25 | 26 | /** 27 | * A notification sent after controller disappears. 28 | */ 29 | extern NSString * const PBPopinControllerDidDisappearNotification; 30 | 31 | /** 32 | * A key for initial rect in userInfo dictionary. 33 | */ 34 | extern NSString* const PBPopinControllerInitialFrameUserInfoKey; 35 | 36 | /** 37 | * A key for final rect in userInfo dictionary. 38 | */ 39 | extern NSString * const PBPopinControllerFinalFrameUserInfoKey; 40 | 41 | /** 42 | * A key for animation duration in userInfo dictionary. 43 | */ 44 | extern NSString* const PBPopinControllerAnimationDurationUserInfoKey; 45 | 46 | /** 47 | * A key for animation curve in userInfo dictionary. 48 | */ 49 | extern NSString* const PBPopinControllerAnimationCurveUserInfoKey; 50 | 51 | 52 | /** 53 | * @abstract Popin controller. 54 | */ 55 | @interface PBPopinController : NSObject 56 | 57 | /** 58 | * A source view controller that requested presentation. 59 | */ 60 | @property (weak, readonly) UIViewController* sourceViewController; 61 | 62 | /** 63 | * A content view controller displayed in popin. 64 | */ 65 | @property (weak, readonly) UIViewController* contentViewController; 66 | 67 | /** 68 | * Indicates whether popin is presented. 69 | */ 70 | @property (readonly) BOOL presented; 71 | 72 | /** 73 | * Get shared instance of popin controller. 74 | * 75 | * @return an instance of PBPopinController 76 | */ 77 | + (instancetype)sharedPopinController; 78 | 79 | /** 80 | * @abstract Present popin controller modally. This usually creates a backdrop overlay. 81 | * @discussion You can call present multiple times, this will replace child controller within presented popin controller. 82 | * 83 | * @param presentedViewController a content controller that will be displayed in popin controller 84 | * @param sourceViewController a source view controller you request presentation from 85 | * @param animated whether to animate transition 86 | * @param completion a completion handler 87 | */ 88 | - (void)presentModalWithContentViewController:(UIViewController*)contentViewController 89 | fromViewController:(UIViewController*)sourceViewController 90 | animated:(BOOL)animated 91 | completion:(void(^)(void))completion; 92 | 93 | /** 94 | * @abstract Present popin controller. 95 | * @discussion You can call present multiple times, this will replace child controller within presented popin controller. 96 | * 97 | * @param presentedViewController a content controller that will be displayed in popin controller 98 | * @param sourceViewController a source view controller you request presentation from 99 | * @param animated whether to animate transition 100 | * @param completion a completion handler 101 | */ 102 | - (void)presentWithContentViewController:(UIViewController*)contentViewController 103 | fromViewController:(UIViewController*)sourceViewController 104 | animated:(BOOL)animated 105 | completion:(void(^)(void))completion; 106 | 107 | /** 108 | * @abstract Dismiss popin controller. 109 | * @discussion Make sure you call it only if controller is presented. 110 | * 111 | * @param animated whether to animate transition 112 | * @param completion a completion handler 113 | */ 114 | - (void)dismissAnimated:(BOOL)animated completion:(void(^)(void))completion; 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /PBControllerDemo/TableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.m 3 | // PBControllerDemo 4 | // 5 | // Created by pronebird on 2/23/15. 6 | // Copyright (c) 2015 pronebird. All rights reserved. 7 | // 8 | 9 | #import "TableViewController.h" 10 | #import "DatePickerViewController.h" 11 | #import "CountryPickerViewController.h" 12 | #import "PictureViewController.h" 13 | #import "PBPopinController.h" 14 | 15 | @interface TableViewController() 16 | 17 | @property (weak) DatePickerViewController* datePickerController; 18 | 19 | @end 20 | 21 | @implementation TableViewController 22 | 23 | #pragma mark - View lifecycle 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | self.textField.inputAccessoryView = self.keyboardAccessory; 29 | } 30 | 31 | #pragma mark - Segue 32 | 33 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 34 | if([segue.identifier isEqualToString:@"ChooseDate"]) { 35 | [self handleDatePickerSegue:segue]; 36 | } 37 | else if([segue.identifier isEqualToString:@"ChooseCategory"]) { 38 | [self handleCategoryPickerSegue:segue]; 39 | } 40 | else if([segue.identifier isEqualToString:@"ChoosePhoto"]) { 41 | [self handlePicturePickerSegue:segue]; 42 | } 43 | } 44 | 45 | #pragma mark - UITableView delegate 46 | 47 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 48 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 49 | } 50 | 51 | #pragma mark - Private 52 | 53 | - (void)handleDatePickerSegue:(UIStoryboardSegue*)segue { 54 | DatePickerViewController* datePickerController = (DatePickerViewController*)segue.destinationViewController; 55 | datePickerController.currentDate = self.selectedDate; 56 | datePickerController.didChangeDate = ^(NSDate* date) { 57 | [self updateSelectedDate:date]; 58 | }; 59 | 60 | // add "today" button on toolbar 61 | NSMutableArray* toolbarItems = [self.popinAccessory.items mutableCopy]; 62 | [toolbarItems removeObject:self.todayAccessoryItem]; 63 | [toolbarItems insertObject:self.todayAccessoryItem atIndex:2]; 64 | [self.popinAccessory setItems:toolbarItems]; 65 | 66 | // setup accessory view 67 | datePickerController.popinAccessoryView = self.popinAccessory; 68 | 69 | self.datePickerController = datePickerController; 70 | 71 | [self.textField endEditing:YES]; 72 | } 73 | 74 | - (void)handleCategoryPickerSegue:(UIStoryboardSegue*)segue { 75 | CountryPickerViewController* countryPickerController = (CountryPickerViewController*)segue.destinationViewController; 76 | countryPickerController.initialCountry = self.selectedCountry; 77 | countryPickerController.didSelectCountry = ^(NSString* country) { 78 | self.countryLabel.text = country; 79 | self.selectedCountry = country; 80 | }; 81 | 82 | // remove "today" button from toolbar 83 | NSMutableArray* toolbarItems = [self.popinAccessory.items mutableCopy]; 84 | [toolbarItems removeObject:self.todayAccessoryItem]; 85 | [self.popinAccessory setItems:toolbarItems]; 86 | 87 | // setup accessory view 88 | countryPickerController.popinAccessoryView = self.popinAccessory; 89 | 90 | [self.textField endEditing:YES]; 91 | } 92 | 93 | - (void)handlePicturePickerSegue:(UIStoryboardSegue *)segue { 94 | PictureViewController *pictureController = (PictureViewController *)segue.destinationViewController; 95 | 96 | pictureController.didFinishPickingPhoto = ^(UIImage *image) { 97 | self.photoImageView.image = image; 98 | }; 99 | 100 | [self.textField endEditing:YES]; 101 | } 102 | 103 | - (void)updateSelectedDate:(NSDate*)date { 104 | NSDateFormatter* dateFormatter = [NSDateFormatter new]; 105 | dateFormatter.dateStyle = NSDateFormatterLongStyle; 106 | dateFormatter.timeStyle = NSDateFormatterNoStyle; 107 | 108 | self.dateLabel.text = [dateFormatter stringFromDate:date]; 109 | self.selectedDate = date; 110 | } 111 | 112 | #pragma mark - Actions 113 | 114 | - (IBAction)today:(id)sender { 115 | self.datePickerController.currentDate = [NSDate date]; 116 | [self updateSelectedDate:self.datePickerController.currentDate]; 117 | } 118 | 119 | - (IBAction)done:(id)sender { 120 | // dismiss keyboard 121 | [self.tableView endEditing:YES]; 122 | 123 | // dismiss popin controller 124 | [[PBPopinController sharedPopinController] dismissAnimated:YES completion:nil]; 125 | } 126 | 127 | #pragma mark - UITextFieldDelegate 128 | 129 | - (void)textFieldDidBeginEditing:(UITextField *)textField { 130 | // dismiss popin controller 131 | [[PBPopinController sharedPopinController] dismissAnimated:YES completion:nil]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PBPopinController 2 | 3 | Custom controller that pops from the bottom, exactly like keyboard. 4 | 5 | ![GIF Image](https://raw.githubusercontent.com/pronebird/PBPopinController/master/README%20Images/PopinController.gif) 6 | 7 | #### Features 8 | 9 | 1. Content controller support. 10 | 1. Accessory view support. 11 | 1. Non-modal, creates its own UIWindow and passes through all user interactions within unoccupied by content area. 12 | 1. Dismisses itself on scroll if presented from table or collection view controller. 13 | 1. Uses same animation curve and duration as keyboard. 14 | 1. Knows how to swap content controller if already presented, without unnecessary animations. 15 | 1. Works with storyboards, use custom `PBPopinSegue` or `PBModalPopinSegue`. 16 | 17 | #### Known issues 18 | 19 | 1. Unwinding does not work. Manually dismiss controller. 20 | 2. Does not dismiss itself if presenting controller dismissed. Dismiss manually. 21 | 22 | All contributions, PRs, comments are welcome! 23 | 24 | ### Installation using CocoaPods 25 | 26 | Add the following line in your Podfile: 27 | 28 | ```ruby 29 | pod 'PBPopinController' 30 | ``` 31 | 32 | ### Example 33 | 34 | #### Present a popin controller 35 | 36 | ```objective-c 37 | #import 38 | 39 | @implementation MyViewController 40 | 41 | - (IBAction)handleTapOnButton:(id)sender { 42 | UIViewController* contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ContentVC"]; 43 | [[PBPopinController sharedPopinController] presentWithContentViewController:contentViewController 44 | fromViewController:self 45 | animated:YES 46 | completion:nil]; 47 | } 48 | 49 | @end 50 | 51 | ``` 52 | 53 | #### Dismiss a popin controller from anywhere 54 | 55 | Popin controller is a singleton which means that you can always access it via `[PBPopinController sharedPopinController]`. 56 | 57 | ```objective-c 58 | 59 | if([PBPopinController sharedPopinController].presented) { 60 | [[PBPopinController sharedPopinController] dismissAnimated:YES completion:nil]; 61 | } 62 | 63 | ``` 64 | 65 | #### Dismiss popin controller from content controller 66 | 67 | Content controllers can access associated popin controller via `self.popinController`. This property is set to nil when content controller is about to be removed from popin container or replaced by another controller. 68 | 69 | ```objective-c 70 | 71 | // Important to include this header 72 | #import 73 | 74 | @implementation MyPopinContentViewController 75 | 76 | - (IBAction)done:(id)sender { 77 | [self.popinController dismissAnimated:YES completion:nil]; 78 | } 79 | 80 | @end 81 | 82 | ``` 83 | 84 | #### Content controller size 85 | 86 | By default PopinController will use half of screen to present your content controller. However you can change that by setting a desired `preferredContentSize` on your content view controller. 87 | 88 | #### Accessory view 89 | 90 | You can provide an accessory view to popin controller which is placed above content view. Popin controller uses `intrinsicContentSize` to calculate size for accessory view. 91 | 92 | Make sure you do not share the same accessory view with keyboard or any other view since it may lead to crash, e.g. keyboard explicitly checks for that and raises exception. 93 | 94 | Although pop-in controller handles this properly when the same accessory view is shared between pop-in presentations. 95 | 96 | ```objc 97 | // setup toolbar accessory view 98 | UIToolbar* accessory = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 44)]; 99 | accessory.items = @[ /* ... */ ]; 100 | 101 | // create content controller 102 | UIViewController* contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ContentVC"]; 103 | 104 | // assign accessory view 105 | contentViewController.popinAccessoryView = accessory; 106 | 107 | // present pop-in controller 108 | [[PBPopinController sharedPopinController] presentWithContentViewController:contentViewController 109 | fromViewController:self 110 | animated:YES 111 | completion:nil]; 112 | ``` 113 | 114 | #### Storyboard 115 | 116 | Popin controller comes with a custom segue `PBPopinSegue` that you can use to wire controllers in Storyboard. You still have to dismiss controller manually in code though. 117 | 118 | Please take a look at demo app coming with this pod: 119 | 120 | ```bash 121 | pod try PBPopinController 122 | ``` 123 | -------------------------------------------------------------------------------- /Classes/PBPopinController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinController.m 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import "PBPopinController.h" 9 | #import "PBPopinContainerViewController.h" 10 | #import "UIViewController+PopinController.h" 11 | 12 | NSString* const PBPopinControllerWillAppearNotification = @"PBPopinControllerWillAppearNotification"; 13 | NSString* const PBPopinControllerDidAppearNotification = @"PBPopinControllerDidAppearNotification"; 14 | NSString* const PBPopinControllerWillDisappearNotification = @"PBPopinControllerWillDisappearNotification"; 15 | NSString* const PBPopinControllerDidDisappearNotification = @"PBPopinControllerDidDisappearNotification"; 16 | 17 | NSString* const PBPopinControllerInitialFrameUserInfoKey = @"initialFrame"; 18 | NSString* const PBPopinControllerFinalFrameUserInfoKey = @"finalFrame"; 19 | NSString* const PBPopinControllerAnimationDurationUserInfoKey = @"animationDuration"; 20 | NSString* const PBPopinControllerAnimationCurveUserInfoKey = @"animationCurve"; 21 | 22 | @interface _PBPopinWindow : UIWindow 23 | 24 | @property BOOL passthroughTouches; 25 | 26 | @end 27 | 28 | @implementation _PBPopinWindow 29 | 30 | - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { 31 | if(!self.passthroughTouches) { 32 | return [super pointInside:point withEvent:event]; 33 | } 34 | 35 | PBPopinContainerViewController* container = (PBPopinContainerViewController *)self.rootViewController; 36 | UIView* transitionView = container.contentViewController.view.superview; 37 | 38 | if(!CGRectContainsPoint(transitionView.frame, point)) { 39 | return NO; 40 | } 41 | 42 | return YES; 43 | } 44 | 45 | @end 46 | 47 | @interface UIViewController () 48 | 49 | @property (readwrite, nonatomic) PBPopinController* popinController; 50 | 51 | @end 52 | 53 | @interface PBPopinController() 54 | 55 | @property PBPopinContainerViewController* containerController; 56 | @property (weak, readwrite) UIViewController* sourceViewController; 57 | @property (weak, readwrite) UIViewController* contentViewController; 58 | @property (readwrite) BOOL presented; 59 | @property UITapGestureRecognizer *dismissTapGestureRecognizer; 60 | 61 | @property UIEdgeInsets scrollViewContentInsets; 62 | 63 | @end 64 | 65 | @implementation PBPopinController 66 | 67 | + (instancetype)sharedPopinController { 68 | static id popinController; 69 | static dispatch_once_t onceToken; 70 | dispatch_once(&onceToken, ^{ 71 | popinController = [PBPopinController new]; 72 | }); 73 | return popinController; 74 | } 75 | 76 | + (_PBPopinWindow*)popinWindow { 77 | static _PBPopinWindow* popinWindow; 78 | static dispatch_once_t onceToken; 79 | dispatch_once(&onceToken, ^{ 80 | popinWindow = [[_PBPopinWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 81 | popinWindow.backgroundColor = [UIColor clearColor]; 82 | }); 83 | return popinWindow; 84 | } 85 | 86 | - (void)presentModalWithContentViewController:(UIViewController*)contentViewController 87 | fromViewController:(UIViewController*)sourceViewController 88 | animated:(BOOL)animated 89 | completion:(void(^)(void))completion; 90 | { 91 | [self _presentWithContentViewController:contentViewController 92 | fromViewController:sourceViewController 93 | modal:YES 94 | animated:animated 95 | completion:completion]; 96 | } 97 | 98 | - (void)presentWithContentViewController:(UIViewController*)contentViewController 99 | fromViewController:(UIViewController*)sourceViewController 100 | animated:(BOOL)animated 101 | completion:(void(^)(void))completion { 102 | [self _presentWithContentViewController:contentViewController 103 | fromViewController:sourceViewController 104 | modal:NO 105 | animated:animated 106 | completion:completion]; 107 | } 108 | 109 | - (void)dismissAnimated:(BOOL)animated completion:(void(^)(void))completion { 110 | if(!self.presented) { 111 | if(completion) { 112 | completion(); 113 | } 114 | return; 115 | } 116 | 117 | __weak typeof(self) weakSelf = self; 118 | 119 | [self _sendControllerWillDisappearNotification:animated]; 120 | 121 | self.presented = NO; 122 | [self _removeDismissOnScrollHandler]; 123 | [self _removeDismissOnBackdropTap]; 124 | 125 | [self.containerController setContentViewController:nil animated:animated alongsideAnimation:^{ 126 | __strong typeof(weakSelf) strongSelf = weakSelf; 127 | 128 | // fade backdrop 129 | strongSelf.containerController.showsBackdrop = NO; 130 | } completion:^{ 131 | __strong typeof(weakSelf) strongSelf = weakSelf; 132 | 133 | // check if still dismissed 134 | if(!strongSelf.presented) { 135 | [strongSelf.class popinWindow].rootViewController = nil; 136 | strongSelf.containerController = nil; 137 | strongSelf.contentViewController.popinController = nil; 138 | 139 | [[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible]; 140 | [strongSelf _hidePopinWindow]; 141 | 142 | [[NSNotificationCenter defaultCenter] postNotificationName:PBPopinControllerDidDisappearNotification object:nil]; 143 | } 144 | 145 | if(completion) { 146 | completion(); 147 | } 148 | }]; 149 | } 150 | 151 | #pragma mark - Private 152 | 153 | - (void)_showPopinWindow { 154 | [self.class popinWindow].hidden = NO; 155 | [[self.class popinWindow] makeKeyAndVisible]; 156 | } 157 | 158 | - (void)_hidePopinWindow { 159 | [self.class popinWindow].hidden = YES; 160 | } 161 | 162 | - (void)_presentWithContentViewController:(UIViewController*)contentViewController 163 | fromViewController:(UIViewController*)sourceViewController 164 | modal:(BOOL)modal 165 | animated:(BOOL)animated 166 | completion:(void(^)(void))completion 167 | { 168 | NSParameterAssert(contentViewController); 169 | NSParameterAssert(sourceViewController); 170 | 171 | // we present without animation only when we replace already presented controller 172 | BOOL shouldReplaceContent = self.presented; 173 | 174 | // set touches passthrough 175 | [self.class popinWindow].passthroughTouches = !modal; 176 | 177 | // remove gestures 178 | [self _removeDismissOnBackdropTap]; 179 | [self _removeDismissOnScrollHandler]; 180 | 181 | // assign popinController to content controller 182 | contentViewController.popinController = self; 183 | 184 | void(^alongsideAnimation)(void) = ^{ 185 | // backdrop will be animated alongside 186 | // and animated individually when replacing controller 187 | [self.containerController setShowsBackdrop:modal animated:shouldReplaceContent]; 188 | }; 189 | 190 | void(^animationFinished)(void) = ^{ 191 | if(completion) { 192 | completion(); 193 | } 194 | 195 | if(!self.presented) { // can be dismissed in between transition. 196 | return; 197 | } 198 | 199 | if(modal) { 200 | // add dismiss on tap handler when using modal presentation 201 | [self _addDismissOnBackdropTap]; 202 | } 203 | else { 204 | // add dismiss on scroll handler when using non-modal presentation 205 | [self _addDismissOnScrollHandler:sourceViewController]; 206 | } 207 | }; 208 | 209 | // Replace content view controller if controller is already presented 210 | if(shouldReplaceContent) 211 | { 212 | self.contentViewController.popinController = nil; 213 | 214 | self.contentViewController = contentViewController; 215 | self.sourceViewController = sourceViewController; 216 | 217 | self.containerController.sourceViewController = self.sourceViewController; 218 | 219 | [self.containerController setContentViewController:contentViewController 220 | animated:NO 221 | alongsideAnimation:alongsideAnimation 222 | completion:animationFinished]; 223 | 224 | if(completion) { 225 | completion(); 226 | } 227 | } 228 | else 229 | { 230 | self.presented = YES; 231 | 232 | self.contentViewController = contentViewController; 233 | self.sourceViewController = sourceViewController; 234 | 235 | self.containerController = [[PBPopinContainerViewController alloc] initWithContentViewController:nil]; 236 | self.containerController.sourceViewController = self.sourceViewController; 237 | 238 | [self.class popinWindow].rootViewController = self.containerController; 239 | [self _showPopinWindow]; 240 | 241 | [self _sendControllerWillAppearNotication:animated]; 242 | 243 | __weak typeof(self) weakSelf = self; 244 | 245 | [self.containerController setContentViewController:self.contentViewController animated:animated alongsideAnimation:alongsideAnimation completion:^{ 246 | __strong typeof(weakSelf) strongSelf = weakSelf; 247 | 248 | // check if still presented 249 | if(strongSelf.presented) { 250 | [[NSNotificationCenter defaultCenter] postNotificationName:PBPopinControllerDidAppearNotification object:nil]; 251 | } 252 | 253 | animationFinished(); 254 | }]; 255 | } 256 | } 257 | 258 | #pragma mark - Notifications 259 | 260 | - (NSDictionary *)_transitionInfoForUserInfoDictionary:(BOOL)isAnimatedTransition { 261 | NSMutableDictionary *transitionInfo = [NSMutableDictionary new]; 262 | 263 | transitionInfo[PBPopinControllerAnimationDurationUserInfoKey] = @(isAnimatedTransition ? [self.containerController transitionDuration] : 0); 264 | transitionInfo[PBPopinControllerAnimationCurveUserInfoKey] = @(isAnimatedTransition ? [self.containerController transitionAnimationCurve] : 0); 265 | 266 | return transitionInfo; 267 | } 268 | 269 | - (void)_sendControllerWillAppearNotication:(BOOL)isAnimated { 270 | CGRect initialFrame = [self.containerController initialFrameForTransitionView:self.contentViewController]; 271 | CGRect finalFrame = [self.containerController finalFrameForTransitionView:self.contentViewController]; 272 | 273 | NSDictionary *transitionInfo = [self _transitionInfoForUserInfoDictionary:isAnimated]; 274 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:transitionInfo]; 275 | userInfo[PBPopinControllerInitialFrameUserInfoKey] = [NSValue valueWithCGRect:initialFrame]; 276 | userInfo[PBPopinControllerFinalFrameUserInfoKey] = [NSValue valueWithCGRect:finalFrame]; 277 | 278 | [[NSNotificationCenter defaultCenter] postNotificationName:PBPopinControllerWillAppearNotification object:nil userInfo:userInfo]; 279 | } 280 | 281 | - (void)_sendControllerWillDisappearNotification:(BOOL)isAnimated { 282 | CGRect initialFrame = [self.containerController finalFrameForTransitionView:self.contentViewController]; 283 | CGRect finalFrame = [self.containerController initialFrameForTransitionView:self.contentViewController]; 284 | 285 | NSDictionary *transitionInfo = [self _transitionInfoForUserInfoDictionary:isAnimated]; 286 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:transitionInfo]; 287 | userInfo[PBPopinControllerInitialFrameUserInfoKey] = [NSValue valueWithCGRect:initialFrame]; 288 | userInfo[PBPopinControllerFinalFrameUserInfoKey] = [NSValue valueWithCGRect:finalFrame]; 289 | 290 | [[NSNotificationCenter defaultCenter] postNotificationName:PBPopinControllerWillDisappearNotification object:nil userInfo:userInfo]; 291 | } 292 | 293 | #pragma mark - BackdropView: dismiss on tap 294 | 295 | - (void)_addDismissOnBackdropTap { 296 | [self _removeDismissOnBackdropTap]; 297 | self.dismissTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_handleTapGesture:)]; 298 | [self.containerController.backdropView addGestureRecognizer:self.dismissTapGestureRecognizer]; 299 | } 300 | 301 | - (void)_removeDismissOnBackdropTap { 302 | [[self.dismissTapGestureRecognizer view] removeGestureRecognizer:self.dismissTapGestureRecognizer]; 303 | self.dismissTapGestureRecognizer = nil; 304 | } 305 | 306 | - (void)_handleTapGesture:(UIGestureRecognizer *)gestureRecognizer { 307 | [self dismissAnimated:YES completion:nil]; 308 | } 309 | 310 | #pragma mark - UIScrollView: dismiss on scroll 311 | 312 | - (void)_addDismissOnScrollHandler:(UIViewController*)sourceViewController { 313 | [self _removeDismissOnScrollHandler]; 314 | 315 | if([sourceViewController.view isKindOfClass:UIScrollView.class]) { 316 | UIScrollView* scrollView = (UIScrollView*)sourceViewController.view; 317 | [scrollView.panGestureRecognizer addTarget:self action:@selector(_handlePanGesture:)]; 318 | } 319 | } 320 | 321 | - (void)_removeDismissOnScrollHandler { 322 | if([self.sourceViewController.view isKindOfClass:UIScrollView.class]) { 323 | UIScrollView* scrollView = (UIScrollView*)self.sourceViewController.view; 324 | [scrollView.panGestureRecognizer removeTarget:self action:@selector(_handlePanGesture:)]; 325 | } 326 | } 327 | 328 | - (void)_handlePanGesture:(UIPanGestureRecognizer*)recognizer { 329 | if(recognizer.state == UIGestureRecognizerStateBegan) { 330 | UIScrollView *scrollView = (UIScrollView *)recognizer.view; 331 | 332 | // @TOOD: support interactive mode 333 | if(scrollView.keyboardDismissMode != UIScrollViewKeyboardDismissModeNone) { 334 | [self dismissAnimated:YES completion:nil]; 335 | } 336 | } 337 | } 338 | 339 | @end 340 | -------------------------------------------------------------------------------- /Classes/PBPopinContainerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PBPopinContainerViewController.m 3 | // 4 | // Created by pronebird on 2/22/15. 5 | // Copyright (c) 2015 pronebird. All rights reserved. 6 | // 7 | 8 | #import "PBPopinContainerViewController.h" 9 | #import "UIViewController+PopinController.h" 10 | 11 | #define UIViewAnimationCurveKeyboard 7 12 | 13 | #define MARKER_CLASS(__class, __super) \ 14 | @interface __class : __super @end \ 15 | @implementation __class @end 16 | 17 | // Marker classes for debugging purposes 18 | MARKER_CLASS(_PBPopinBackdropView, UIView) 19 | MARKER_CLASS(_PBPopinTransitionView, UIView) 20 | MARKER_CLASS(_PBPopinContainerView, UIView) 21 | 22 | @interface PBPopinContainerViewController () 23 | 24 | @property (nonatomic, readwrite) UIViewController *contentViewController; 25 | 26 | /** 27 | * This view is used for animations and contains accessory view and content view. 28 | */ 29 | @property UIView *transitionView; 30 | 31 | /** 32 | * Backdrop view. 33 | */ 34 | @property (nonatomic, readwrite) UIView *backdropView; 35 | 36 | @end 37 | 38 | @implementation PBPopinContainerViewController 39 | 40 | - (UIViewController *)childViewControllerForStatusBarStyle { 41 | return [self _viewControllerForHandlingStatusBarAppearance]; 42 | } 43 | 44 | - (UIViewController *)childViewControllerForStatusBarHidden { 45 | return [self _viewControllerForHandlingStatusBarAppearance]; 46 | } 47 | 48 | - (void)loadView { 49 | self.view = [[_PBPopinContainerView alloc] initWithFrame:CGRectZero]; 50 | } 51 | 52 | - (instancetype)initWithContentViewController:(UIViewController*)contentViewController { 53 | if(self = [super init]) { 54 | self.contentViewController = contentViewController; 55 | } 56 | return self; 57 | } 58 | 59 | - (void)setShowsBackdrop:(BOOL)showsBackdrop { 60 | UIColor *backgroundColor; 61 | 62 | if(showsBackdrop) { 63 | backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5]; 64 | } 65 | else { 66 | backgroundColor = [UIColor clearColor]; 67 | } 68 | 69 | self.backdropView.backgroundColor = backgroundColor; 70 | } 71 | 72 | - (void)setShowsBackdrop:(BOOL)showsBackdrop animated:(BOOL)animated { 73 | void(^animationBlock)(void) = ^{ 74 | [self setShowsBackdrop:showsBackdrop]; 75 | }; 76 | 77 | if(animated) { 78 | [UIView animateWithDuration:[self transitionDuration] delay:0.0 options:[self _animationOptions] animations:^{ 79 | [self setShowsBackdrop:showsBackdrop]; 80 | } completion:^(BOOL finished) {}]; 81 | } 82 | else { 83 | animationBlock(); 84 | } 85 | } 86 | 87 | - (void)setContentViewController:(UIViewController *)contentViewController 88 | animated:(BOOL)animated 89 | alongsideAnimation:(void(^)(void))alongsideAnimation 90 | completion:(void(^)(void))completion 91 | { 92 | UIViewController* presentedContentController = self.contentViewController; 93 | 94 | // check if equal 95 | if(contentViewController == presentedContentController) { 96 | if(completion) { 97 | completion(); 98 | } 99 | return; 100 | } 101 | 102 | // set content controller to nil to dismiss presented one 103 | if(!contentViewController) 104 | { 105 | self.contentViewController = nil; 106 | 107 | [self _dismissContentViewController:presentedContentController animated:animated alongsideAnimation:alongsideAnimation completion:^(BOOL finished) { 108 | if(!finished) { 109 | return; 110 | } 111 | 112 | // remove content view controller 113 | [self _removeContentViewController:presentedContentController]; 114 | 115 | if(completion) { 116 | completion(); 117 | } 118 | }]; 119 | } 120 | else if(!presentedContentController) // if there is currently no controller presented 121 | { 122 | self.contentViewController = contentViewController; 123 | 124 | [self _addContentViewController:contentViewController animated:NO]; 125 | [self _presentContentViewController:contentViewController animated:animated alongsideAnimation:alongsideAnimation completion:^(BOOL finished) { 126 | if(!finished) { 127 | return; 128 | } 129 | 130 | if(completion) { 131 | completion(); 132 | } 133 | }]; 134 | } 135 | else // replace current controller 136 | { 137 | self.contentViewController = contentViewController; 138 | 139 | [self _removeContentViewController:presentedContentController]; 140 | [self _addContentViewController:contentViewController animated:YES]; 141 | 142 | if(alongsideAnimation) { 143 | alongsideAnimation(); 144 | } 145 | 146 | if(completion) { 147 | completion(); 148 | } 149 | } 150 | } 151 | 152 | - (void)viewDidLoad { 153 | [super viewDidLoad]; 154 | 155 | // setup backdrop view 156 | self.backdropView = [[_PBPopinBackdropView alloc] initWithFrame:self.view.bounds]; 157 | self.backdropView.translatesAutoresizingMaskIntoConstraints = NO; 158 | self.backdropView.backgroundColor = [UIColor clearColor]; 159 | [self.view addSubview:self.backdropView]; 160 | 161 | NSDictionary *viewsDictionary = @{ @"backdrop": self.backdropView }; 162 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[backdrop]|" options:0 metrics:nil views:viewsDictionary]]; 163 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[backdrop]|" options:0 metrics:nil views:viewsDictionary]]; 164 | 165 | // create transition view 166 | self.transitionView = [[_PBPopinTransitionView alloc] initWithFrame:self.view.bounds]; 167 | [self.view addSubview:self.transitionView]; 168 | 169 | // add content controller if not in hierarchy yet 170 | if(self.contentViewController && self.contentViewController.parentViewController != self) { 171 | [self _addContentViewController:self.contentViewController animated:NO]; 172 | } 173 | } 174 | 175 | #pragma mark - Content size changes 176 | 177 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { 178 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 179 | 180 | [coordinator animateAlongsideTransition:^(id context) { 181 | [self _layoutTransitionViewAnimated:NO]; 182 | } completion:^(id context) {}]; 183 | } 184 | 185 | - (void)preferredContentSizeDidChangeForChildContentContainer:(id)container { 186 | [super preferredContentSizeDidChangeForChildContentContainer:container]; 187 | 188 | [self _layoutTransitionViewAnimated:NO]; 189 | } 190 | 191 | #pragma mark - Presentation animations 192 | 193 | - (CGRect)finalFrameForTransitionView:(UIViewController*)controller { 194 | CGRect transitionRect; 195 | UIView* accessoryView = controller.popinAccessoryView; 196 | 197 | transitionRect.size = [self _sizeForContentController:controller]; 198 | transitionRect.origin.x = 0; 199 | transitionRect.origin.y = CGRectGetHeight(self.view.bounds) - transitionRect.size.height; 200 | 201 | if(accessoryView) { 202 | CGSize accessorySize = [self _sizeForAccessoryView:accessoryView]; 203 | 204 | transitionRect.origin.y -= accessorySize.height; 205 | transitionRect.size.height += accessorySize.height; 206 | } 207 | 208 | return transitionRect; 209 | } 210 | 211 | - (CGRect)initialFrameForTransitionView:(UIViewController*)controller { 212 | CGRect transitionRect = [self finalFrameForTransitionView:controller]; 213 | 214 | transitionRect.origin.y = CGRectGetHeight(self.view.bounds); 215 | 216 | return transitionRect; 217 | } 218 | 219 | - (NSTimeInterval)transitionDuration { 220 | return 0.25; 221 | } 222 | 223 | - (UIViewAnimationCurve)transitionAnimationCurve { 224 | return UIViewAnimationCurveKeyboard; 225 | } 226 | 227 | - (UIViewAnimationOptions)_animationOptions { 228 | return ([self transitionAnimationCurve] << 16) | UIViewAnimationOptionBeginFromCurrentState; 229 | } 230 | 231 | - (void)_presentContentViewController:(UIViewController *)controller 232 | animated:(BOOL)animated 233 | alongsideAnimation:(void(^)(void))alongsideAnimation 234 | completion:(void(^)(BOOL finished))completion 235 | { 236 | CGRect finalFrameForTransitionView = [self finalFrameForTransitionView:controller]; 237 | void(^animations)(void) = ^{ 238 | self.transitionView.frame = finalFrameForTransitionView; 239 | 240 | if(alongsideAnimation) { 241 | alongsideAnimation(); 242 | } 243 | }; 244 | 245 | void(^animationCompletion)(BOOL finished) = ^(BOOL finished) { 246 | if(completion) { 247 | completion(finished); 248 | } 249 | }; 250 | 251 | self.transitionView.frame = [self initialFrameForTransitionView:controller]; 252 | 253 | if(animated) { 254 | [UIView animateWithDuration:[self transitionDuration] 255 | delay:0.0 256 | options:[self _animationOptions] 257 | animations:animations 258 | completion:animationCompletion]; 259 | } else { 260 | animations(); 261 | animationCompletion(YES); 262 | } 263 | } 264 | 265 | - (void)_dismissContentViewController:(UIViewController *)controller 266 | animated:(BOOL)animated 267 | alongsideAnimation:(void(^)(void))alongsideAnimation 268 | completion:(void(^)(BOOL finished))completion 269 | { 270 | CGRect initialFrameForTransitionView = [self initialFrameForTransitionView:controller]; 271 | void(^animations)(void) = ^{ 272 | self.transitionView.frame = initialFrameForTransitionView; 273 | 274 | if(alongsideAnimation) { 275 | alongsideAnimation(); 276 | } 277 | }; 278 | 279 | void(^animationCompletion)(BOOL finished) = ^(BOOL finished) { 280 | if(completion) { 281 | completion(finished); 282 | } 283 | }; 284 | 285 | if(animated) { 286 | [UIView animateWithDuration:[self transitionDuration] 287 | delay:0.0 288 | options:[self _animationOptions] 289 | animations:animations 290 | completion:animationCompletion]; 291 | } else { 292 | animations(); 293 | animationCompletion(YES); 294 | } 295 | } 296 | 297 | #pragma mark - Private 298 | 299 | /** 300 | * @abstract Calculate size for accessory view. 301 | * @discussion This method uses intrinsicContentSize to determine desired size for accessory view. 302 | * @internal 303 | * 304 | * @param accessoryView an instance of accessory view 305 | * 306 | * @return accessory view size or CGSizeZero 307 | */ 308 | - (CGSize)_sizeForAccessoryView:(UIView *)accessoryView { 309 | CGSize size = accessoryView.intrinsicContentSize; 310 | 311 | size.width = CGRectGetWidth(self.view.bounds); 312 | 313 | return size; 314 | } 315 | 316 | /** 317 | * @abstract Calculate size for content controller view. 318 | * @discussion This method uses preferredContentSize to determine desired size for content controller. 319 | * @internal 320 | * 321 | * @param controller a content controller 322 | * 323 | * @return content controller size 324 | */ 325 | - (CGSize)_sizeForContentController:(UIViewController *)controller { 326 | // force viewDidLoad because sometimes preferredContentSize is calculated 327 | // based on intrinsic content size of elements inside of view 328 | [controller view]; 329 | 330 | CGSize preferredSize = [controller preferredContentSize]; 331 | 332 | if(CGSizeEqualToSize(preferredSize, CGSizeZero)) { 333 | preferredSize = CGSizeMake(0, CGRectGetHeight(self.view.bounds) * 0.5); 334 | } 335 | 336 | preferredSize.width = CGRectGetWidth(self.view.bounds); 337 | 338 | return preferredSize; 339 | } 340 | 341 | /** 342 | * Layout accessory and content views in transition view. 343 | * @internal 344 | * 345 | * @param transitionView an instance of transitionView 346 | * @param controller an associated content controller 347 | * @param animated animate frame changes? 348 | */ 349 | - (void)_layoutTransitionViewAnimated:(BOOL)animated { 350 | UIView *accessoryView = self.contentViewController.popinAccessoryView; 351 | 352 | CGSize accessorySize = [self _sizeForAccessoryView:accessoryView]; 353 | CGSize contentSize = [self _sizeForContentController:self.contentViewController]; 354 | CGRect accessoryRect; 355 | CGRect contentRect; 356 | 357 | accessoryRect.origin = CGPointZero; 358 | accessoryRect.size = accessorySize; 359 | 360 | contentRect.origin = CGPointMake(0, accessorySize.height); 361 | contentRect.size = contentSize; 362 | 363 | CGRect transitionRect = [self finalFrameForTransitionView:self.contentViewController]; 364 | 365 | if(animated) { 366 | [UIView animateWithDuration:[self transitionDuration] 367 | delay:0.0 368 | options:[self _animationOptions] 369 | animations:^{ 370 | self.transitionView.frame = transitionRect; 371 | } completion:^(BOOL finished) { 372 | 373 | }]; 374 | } 375 | else { 376 | self.transitionView.frame = transitionRect; 377 | } 378 | 379 | self.contentViewController.view.frame = contentRect; 380 | accessoryView.frame = accessoryRect; 381 | } 382 | 383 | /** 384 | * Add content view controller into view hierarchy. 385 | * @internal 386 | * 387 | * @param controller an instance of content view controller 388 | * @param transitionView an instance of transition view 389 | * @param animated perform animated transition? 390 | */ 391 | - (void)_addContentViewController:(UIViewController *)controller animated:(BOOL)animated { 392 | UIView* accessoryView = controller.popinAccessoryView; 393 | 394 | // sharing the same accessory between popin controllers is ok, 395 | // but keyboard will throw an exception or mess view hierarchy. 396 | if(accessoryView.superview && ![accessoryView.superview isKindOfClass:_PBPopinTransitionView.class]) { 397 | [NSException raise:@"PBPopinContainerViewControllerHierarchyInconsistencyException" 398 | format:@"Popin accessory view must not be in view hierarchy. Please create an individual instance of accessory view."]; 399 | } 400 | 401 | [self addChildViewController:controller]; 402 | [self.transitionView addSubview:controller.view]; 403 | [controller didMoveToParentViewController:self]; 404 | 405 | if(accessoryView) { 406 | // remove all constraints 407 | if(accessoryView.constraints.count) { 408 | [accessoryView removeConstraints:accessoryView.constraints]; 409 | } 410 | 411 | accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 412 | accessoryView.translatesAutoresizingMaskIntoConstraints = YES; 413 | 414 | [self.transitionView addSubview:accessoryView]; 415 | } 416 | 417 | [self _layoutTransitionViewAnimated:animated]; 418 | 419 | // update statusbar appearance after adding new content controller 420 | [self setNeedsStatusBarAppearanceUpdate]; 421 | } 422 | 423 | /** 424 | * Remove content view controller from view hierarchy. 425 | * @internal 426 | * 427 | * @param controller an instance of content view controller 428 | * @param transitionView an instance of transition view 429 | */ 430 | - (void)_removeContentViewController:(UIViewController *)controller { 431 | [controller willMoveToParentViewController:nil]; 432 | [controller.view removeFromSuperview]; 433 | [controller removeFromParentViewController]; 434 | 435 | // Edge case: same accessory can be reused so make sure we remove it from our own views only 436 | UIView *accessoryView = controller.popinAccessoryView; 437 | if(accessoryView.superview == self.transitionView) { 438 | [accessoryView removeFromSuperview]; 439 | } 440 | } 441 | 442 | /** 443 | * Find out controller that should handle status bar appearance 444 | * 445 | * @return UIViewController 446 | */ 447 | - (UIViewController *)_viewControllerForHandlingStatusBarAppearance { 448 | /* 449 | Let UIKit container controllers handle appearance when possible 450 | */ 451 | if(self.sourceViewController.navigationController) { 452 | return self.sourceViewController.navigationController; 453 | } 454 | 455 | if(self.sourceViewController.tabBarController) { 456 | return self.sourceViewController.tabBarController; 457 | } 458 | 459 | if(self.sourceViewController.splitViewController) { 460 | return self.sourceViewController.splitViewController; 461 | } 462 | 463 | /* 464 | Otherwise let source controller handle appearance himself 465 | */ 466 | return self.sourceViewController; 467 | } 468 | 469 | @end 470 | -------------------------------------------------------------------------------- /PBControllerDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | -------------------------------------------------------------------------------- /PBControllerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 583CA7871ACAE75900C560B0 /* PBModalPopinSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = 583CA7861ACAE75900C560B0 /* PBModalPopinSegue.m */; }; 11 | 583CA78A1ACAE9A300C560B0 /* PictureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 583CA7891ACAE9A300C560B0 /* PictureViewController.m */; }; 12 | 58B964E11A9B485C00C8E8AD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B964E01A9B485C00C8E8AD /* main.m */; }; 13 | 58B964E41A9B485C00C8E8AD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B964E31A9B485C00C8E8AD /* AppDelegate.m */; }; 14 | 58B964EA1A9B485C00C8E8AD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 58B964E81A9B485C00C8E8AD /* Main.storyboard */; }; 15 | 58B964EC1A9B485C00C8E8AD /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 58B964EB1A9B485C00C8E8AD /* Images.xcassets */; }; 16 | 58B964EF1A9B485C00C8E8AD /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 58B964ED1A9B485C00C8E8AD /* LaunchScreen.xib */; }; 17 | 58B964FB1A9B485C00C8E8AD /* PBControllerDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B964FA1A9B485C00C8E8AD /* PBControllerDemoTests.m */; }; 18 | 58B9650E1A9B489F00C8E8AD /* PBPopinContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B965051A9B489F00C8E8AD /* PBPopinContainerViewController.m */; }; 19 | 58B9650F1A9B489F00C8E8AD /* PBPopinController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B965071A9B489F00C8E8AD /* PBPopinController.m */; }; 20 | 58B965101A9B489F00C8E8AD /* PBPopinSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B965091A9B489F00C8E8AD /* PBPopinSegue.m */; }; 21 | 58B965121A9B489F00C8E8AD /* UIViewController+PopinController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B9650D1A9B489F00C8E8AD /* UIViewController+PopinController.m */; }; 22 | 58B965161A9B4AF200C8E8AD /* DatePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B965151A9B4AF200C8E8AD /* DatePickerViewController.m */; }; 23 | 58B965191A9B4B5900C8E8AD /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B965181A9B4B5900C8E8AD /* TableViewController.m */; }; 24 | 58B9651C1A9B4E0800C8E8AD /* CountryPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B9651B1A9B4E0800C8E8AD /* CountryPickerViewController.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 58B964F51A9B485C00C8E8AD /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 58B964D31A9B485C00C8E8AD /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 58B964DA1A9B485C00C8E8AD; 33 | remoteInfo = PBControllerDemo; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 583CA7851ACAE75900C560B0 /* PBModalPopinSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PBModalPopinSegue.h; path = Classes/PBModalPopinSegue.h; sourceTree = SOURCE_ROOT; }; 39 | 583CA7861ACAE75900C560B0 /* PBModalPopinSegue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PBModalPopinSegue.m; path = Classes/PBModalPopinSegue.m; sourceTree = SOURCE_ROOT; }; 40 | 583CA7881ACAE9A300C560B0 /* PictureViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PictureViewController.h; sourceTree = ""; }; 41 | 583CA7891ACAE9A300C560B0 /* PictureViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PictureViewController.m; sourceTree = ""; }; 42 | 58B964DB1A9B485C00C8E8AD /* PBControllerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PBControllerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 58B964DF1A9B485C00C8E8AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 58B964E01A9B485C00C8E8AD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 58B964E21A9B485C00C8E8AD /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 58B964E31A9B485C00C8E8AD /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 58B964E91A9B485C00C8E8AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 58B964EB1A9B485C00C8E8AD /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 49 | 58B964EE1A9B485C00C8E8AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 50 | 58B964F41A9B485C00C8E8AD /* PBControllerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PBControllerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 58B964F91A9B485C00C8E8AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 58B964FA1A9B485C00C8E8AD /* PBControllerDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PBControllerDemoTests.m; sourceTree = ""; }; 53 | 58B965041A9B489F00C8E8AD /* PBPopinContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PBPopinContainerViewController.h; path = Classes/PBPopinContainerViewController.h; sourceTree = SOURCE_ROOT; }; 54 | 58B965051A9B489F00C8E8AD /* PBPopinContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PBPopinContainerViewController.m; path = Classes/PBPopinContainerViewController.m; sourceTree = SOURCE_ROOT; }; 55 | 58B965061A9B489F00C8E8AD /* PBPopinController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PBPopinController.h; path = Classes/PBPopinController.h; sourceTree = SOURCE_ROOT; }; 56 | 58B965071A9B489F00C8E8AD /* PBPopinController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PBPopinController.m; path = Classes/PBPopinController.m; sourceTree = SOURCE_ROOT; }; 57 | 58B965081A9B489F00C8E8AD /* PBPopinSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PBPopinSegue.h; path = Classes/PBPopinSegue.h; sourceTree = SOURCE_ROOT; }; 58 | 58B965091A9B489F00C8E8AD /* PBPopinSegue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PBPopinSegue.m; path = Classes/PBPopinSegue.m; sourceTree = SOURCE_ROOT; }; 59 | 58B9650C1A9B489F00C8E8AD /* UIViewController+PopinController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+PopinController.h"; path = "Classes/UIViewController+PopinController.h"; sourceTree = SOURCE_ROOT; }; 60 | 58B9650D1A9B489F00C8E8AD /* UIViewController+PopinController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+PopinController.m"; path = "Classes/UIViewController+PopinController.m"; sourceTree = SOURCE_ROOT; }; 61 | 58B965141A9B4AF200C8E8AD /* DatePickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatePickerViewController.h; sourceTree = ""; }; 62 | 58B965151A9B4AF200C8E8AD /* DatePickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatePickerViewController.m; sourceTree = ""; }; 63 | 58B965171A9B4B5900C8E8AD /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = ""; }; 64 | 58B965181A9B4B5900C8E8AD /* TableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewController.m; sourceTree = ""; }; 65 | 58B9651A1A9B4E0800C8E8AD /* CountryPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountryPickerViewController.h; sourceTree = ""; }; 66 | 58B9651B1A9B4E0800C8E8AD /* CountryPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountryPickerViewController.m; sourceTree = ""; }; 67 | /* End PBXFileReference section */ 68 | 69 | /* Begin PBXFrameworksBuildPhase section */ 70 | 58B964D81A9B485C00C8E8AD /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 58B964F11A9B485C00C8E8AD /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | 58B964D21A9B485C00C8E8AD = { 88 | isa = PBXGroup; 89 | children = ( 90 | 58B964DD1A9B485C00C8E8AD /* PBControllerDemo */, 91 | 58B964F71A9B485C00C8E8AD /* PBControllerDemoTests */, 92 | 58B964DC1A9B485C00C8E8AD /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 58B964DC1A9B485C00C8E8AD /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 58B964DB1A9B485C00C8E8AD /* PBControllerDemo.app */, 100 | 58B964F41A9B485C00C8E8AD /* PBControllerDemoTests.xctest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 58B964DD1A9B485C00C8E8AD /* PBControllerDemo */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 58B965131A9B48A400C8E8AD /* Classes */, 109 | 58B964E21A9B485C00C8E8AD /* AppDelegate.h */, 110 | 58B964E31A9B485C00C8E8AD /* AppDelegate.m */, 111 | 58B965171A9B4B5900C8E8AD /* TableViewController.h */, 112 | 58B965181A9B4B5900C8E8AD /* TableViewController.m */, 113 | 58B965141A9B4AF200C8E8AD /* DatePickerViewController.h */, 114 | 58B965151A9B4AF200C8E8AD /* DatePickerViewController.m */, 115 | 58B9651A1A9B4E0800C8E8AD /* CountryPickerViewController.h */, 116 | 58B9651B1A9B4E0800C8E8AD /* CountryPickerViewController.m */, 117 | 583CA7881ACAE9A300C560B0 /* PictureViewController.h */, 118 | 583CA7891ACAE9A300C560B0 /* PictureViewController.m */, 119 | 58B964E81A9B485C00C8E8AD /* Main.storyboard */, 120 | 58B964EB1A9B485C00C8E8AD /* Images.xcassets */, 121 | 58B964ED1A9B485C00C8E8AD /* LaunchScreen.xib */, 122 | 58B964DE1A9B485C00C8E8AD /* Supporting Files */, 123 | ); 124 | path = PBControllerDemo; 125 | sourceTree = ""; 126 | }; 127 | 58B964DE1A9B485C00C8E8AD /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 58B964DF1A9B485C00C8E8AD /* Info.plist */, 131 | 58B964E01A9B485C00C8E8AD /* main.m */, 132 | ); 133 | name = "Supporting Files"; 134 | sourceTree = ""; 135 | }; 136 | 58B964F71A9B485C00C8E8AD /* PBControllerDemoTests */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 58B964FA1A9B485C00C8E8AD /* PBControllerDemoTests.m */, 140 | 58B964F81A9B485C00C8E8AD /* Supporting Files */, 141 | ); 142 | path = PBControllerDemoTests; 143 | sourceTree = ""; 144 | }; 145 | 58B964F81A9B485C00C8E8AD /* Supporting Files */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 58B964F91A9B485C00C8E8AD /* Info.plist */, 149 | ); 150 | name = "Supporting Files"; 151 | sourceTree = ""; 152 | }; 153 | 58B965131A9B48A400C8E8AD /* Classes */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 58B965041A9B489F00C8E8AD /* PBPopinContainerViewController.h */, 157 | 58B965051A9B489F00C8E8AD /* PBPopinContainerViewController.m */, 158 | 58B965061A9B489F00C8E8AD /* PBPopinController.h */, 159 | 58B965071A9B489F00C8E8AD /* PBPopinController.m */, 160 | 58B965081A9B489F00C8E8AD /* PBPopinSegue.h */, 161 | 58B965091A9B489F00C8E8AD /* PBPopinSegue.m */, 162 | 583CA7851ACAE75900C560B0 /* PBModalPopinSegue.h */, 163 | 583CA7861ACAE75900C560B0 /* PBModalPopinSegue.m */, 164 | 58B9650C1A9B489F00C8E8AD /* UIViewController+PopinController.h */, 165 | 58B9650D1A9B489F00C8E8AD /* UIViewController+PopinController.m */, 166 | ); 167 | name = Classes; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXGroup section */ 171 | 172 | /* Begin PBXNativeTarget section */ 173 | 58B964DA1A9B485C00C8E8AD /* PBControllerDemo */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = 58B964FE1A9B485C00C8E8AD /* Build configuration list for PBXNativeTarget "PBControllerDemo" */; 176 | buildPhases = ( 177 | 58B964D71A9B485C00C8E8AD /* Sources */, 178 | 58B964D81A9B485C00C8E8AD /* Frameworks */, 179 | 58B964D91A9B485C00C8E8AD /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = PBControllerDemo; 186 | productName = PBControllerDemo; 187 | productReference = 58B964DB1A9B485C00C8E8AD /* PBControllerDemo.app */; 188 | productType = "com.apple.product-type.application"; 189 | }; 190 | 58B964F31A9B485C00C8E8AD /* PBControllerDemoTests */ = { 191 | isa = PBXNativeTarget; 192 | buildConfigurationList = 58B965011A9B485C00C8E8AD /* Build configuration list for PBXNativeTarget "PBControllerDemoTests" */; 193 | buildPhases = ( 194 | 58B964F01A9B485C00C8E8AD /* Sources */, 195 | 58B964F11A9B485C00C8E8AD /* Frameworks */, 196 | 58B964F21A9B485C00C8E8AD /* Resources */, 197 | ); 198 | buildRules = ( 199 | ); 200 | dependencies = ( 201 | 58B964F61A9B485C00C8E8AD /* PBXTargetDependency */, 202 | ); 203 | name = PBControllerDemoTests; 204 | productName = PBControllerDemoTests; 205 | productReference = 58B964F41A9B485C00C8E8AD /* PBControllerDemoTests.xctest */; 206 | productType = "com.apple.product-type.bundle.unit-test"; 207 | }; 208 | /* End PBXNativeTarget section */ 209 | 210 | /* Begin PBXProject section */ 211 | 58B964D31A9B485C00C8E8AD /* Project object */ = { 212 | isa = PBXProject; 213 | attributes = { 214 | LastUpgradeCheck = 0620; 215 | ORGANIZATIONNAME = pronebird; 216 | TargetAttributes = { 217 | 58B964DA1A9B485C00C8E8AD = { 218 | CreatedOnToolsVersion = 6.2; 219 | DevelopmentTeam = PR2A98QJ89; 220 | }; 221 | 58B964F31A9B485C00C8E8AD = { 222 | CreatedOnToolsVersion = 6.2; 223 | TestTargetID = 58B964DA1A9B485C00C8E8AD; 224 | }; 225 | }; 226 | }; 227 | buildConfigurationList = 58B964D61A9B485C00C8E8AD /* Build configuration list for PBXProject "PBControllerDemo" */; 228 | compatibilityVersion = "Xcode 3.2"; 229 | developmentRegion = English; 230 | hasScannedForEncodings = 0; 231 | knownRegions = ( 232 | en, 233 | Base, 234 | ); 235 | mainGroup = 58B964D21A9B485C00C8E8AD; 236 | productRefGroup = 58B964DC1A9B485C00C8E8AD /* Products */; 237 | projectDirPath = ""; 238 | projectRoot = ""; 239 | targets = ( 240 | 58B964DA1A9B485C00C8E8AD /* PBControllerDemo */, 241 | 58B964F31A9B485C00C8E8AD /* PBControllerDemoTests */, 242 | ); 243 | }; 244 | /* End PBXProject section */ 245 | 246 | /* Begin PBXResourcesBuildPhase section */ 247 | 58B964D91A9B485C00C8E8AD /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 58B964EA1A9B485C00C8E8AD /* Main.storyboard in Resources */, 252 | 58B964EF1A9B485C00C8E8AD /* LaunchScreen.xib in Resources */, 253 | 58B964EC1A9B485C00C8E8AD /* Images.xcassets in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 58B964F21A9B485C00C8E8AD /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | /* End PBXResourcesBuildPhase section */ 265 | 266 | /* Begin PBXSourcesBuildPhase section */ 267 | 58B964D71A9B485C00C8E8AD /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 58B9651C1A9B4E0800C8E8AD /* CountryPickerViewController.m in Sources */, 272 | 58B965101A9B489F00C8E8AD /* PBPopinSegue.m in Sources */, 273 | 58B964E41A9B485C00C8E8AD /* AppDelegate.m in Sources */, 274 | 58B965121A9B489F00C8E8AD /* UIViewController+PopinController.m in Sources */, 275 | 58B9650F1A9B489F00C8E8AD /* PBPopinController.m in Sources */, 276 | 58B965191A9B4B5900C8E8AD /* TableViewController.m in Sources */, 277 | 583CA7871ACAE75900C560B0 /* PBModalPopinSegue.m in Sources */, 278 | 58B9650E1A9B489F00C8E8AD /* PBPopinContainerViewController.m in Sources */, 279 | 58B965161A9B4AF200C8E8AD /* DatePickerViewController.m in Sources */, 280 | 58B964E11A9B485C00C8E8AD /* main.m in Sources */, 281 | 583CA78A1ACAE9A300C560B0 /* PictureViewController.m in Sources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 58B964F01A9B485C00C8E8AD /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | 58B964FB1A9B485C00C8E8AD /* PBControllerDemoTests.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | /* End PBXSourcesBuildPhase section */ 294 | 295 | /* Begin PBXTargetDependency section */ 296 | 58B964F61A9B485C00C8E8AD /* PBXTargetDependency */ = { 297 | isa = PBXTargetDependency; 298 | target = 58B964DA1A9B485C00C8E8AD /* PBControllerDemo */; 299 | targetProxy = 58B964F51A9B485C00C8E8AD /* PBXContainerItemProxy */; 300 | }; 301 | /* End PBXTargetDependency section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | 58B964E81A9B485C00C8E8AD /* Main.storyboard */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | 58B964E91A9B485C00C8E8AD /* Base */, 308 | ); 309 | name = Main.storyboard; 310 | sourceTree = ""; 311 | }; 312 | 58B964ED1A9B485C00C8E8AD /* LaunchScreen.xib */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 58B964EE1A9B485C00C8E8AD /* Base */, 316 | ); 317 | name = LaunchScreen.xib; 318 | sourceTree = ""; 319 | }; 320 | /* End PBXVariantGroup section */ 321 | 322 | /* Begin XCBuildConfiguration section */ 323 | 58B964FC1A9B485C00C8E8AD /* Debug */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INT_CONVERSION = YES; 337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 338 | CLANG_WARN_UNREACHABLE_CODE = YES; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 341 | COPY_PHASE_STRIP = NO; 342 | ENABLE_STRICT_OBJC_MSGSEND = YES; 343 | GCC_C_LANGUAGE_STANDARD = gnu99; 344 | GCC_DYNAMIC_NO_PIC = NO; 345 | GCC_OPTIMIZATION_LEVEL = 0; 346 | GCC_PREPROCESSOR_DEFINITIONS = ( 347 | "DEBUG=1", 348 | "$(inherited)", 349 | ); 350 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 351 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 352 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 353 | GCC_WARN_UNDECLARED_SELECTOR = YES; 354 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 355 | GCC_WARN_UNUSED_FUNCTION = YES; 356 | GCC_WARN_UNUSED_VARIABLE = YES; 357 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 358 | MTL_ENABLE_DEBUG_INFO = YES; 359 | ONLY_ACTIVE_ARCH = YES; 360 | SDKROOT = iphoneos; 361 | }; 362 | name = Debug; 363 | }; 364 | 58B964FD1A9B485C00C8E8AD /* Release */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ALWAYS_SEARCH_USER_PATHS = NO; 368 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 369 | CLANG_CXX_LIBRARY = "libc++"; 370 | CLANG_ENABLE_MODULES = YES; 371 | CLANG_ENABLE_OBJC_ARC = YES; 372 | CLANG_WARN_BOOL_CONVERSION = YES; 373 | CLANG_WARN_CONSTANT_CONVERSION = YES; 374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 375 | CLANG_WARN_EMPTY_BODY = YES; 376 | CLANG_WARN_ENUM_CONVERSION = YES; 377 | CLANG_WARN_INT_CONVERSION = YES; 378 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 379 | CLANG_WARN_UNREACHABLE_CODE = YES; 380 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 381 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 382 | COPY_PHASE_STRIP = NO; 383 | ENABLE_NS_ASSERTIONS = NO; 384 | ENABLE_STRICT_OBJC_MSGSEND = YES; 385 | GCC_C_LANGUAGE_STANDARD = gnu99; 386 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 387 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 388 | GCC_WARN_UNDECLARED_SELECTOR = YES; 389 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 390 | GCC_WARN_UNUSED_FUNCTION = YES; 391 | GCC_WARN_UNUSED_VARIABLE = YES; 392 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 393 | MTL_ENABLE_DEBUG_INFO = NO; 394 | SDKROOT = iphoneos; 395 | VALIDATE_PRODUCT = YES; 396 | }; 397 | name = Release; 398 | }; 399 | 58B964FF1A9B485C00C8E8AD /* Debug */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 403 | CODE_SIGN_IDENTITY = "iPhone Developer"; 404 | INFOPLIST_FILE = PBControllerDemo/Info.plist; 405 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | }; 409 | name = Debug; 410 | }; 411 | 58B965001A9B485C00C8E8AD /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | CODE_SIGN_IDENTITY = "iPhone Developer"; 416 | INFOPLIST_FILE = PBControllerDemo/Info.plist; 417 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 418 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | }; 421 | name = Release; 422 | }; 423 | 58B965021A9B485C00C8E8AD /* Debug */ = { 424 | isa = XCBuildConfiguration; 425 | buildSettings = { 426 | BUNDLE_LOADER = "$(TEST_HOST)"; 427 | FRAMEWORK_SEARCH_PATHS = ( 428 | "$(SDKROOT)/Developer/Library/Frameworks", 429 | "$(inherited)", 430 | ); 431 | GCC_PREPROCESSOR_DEFINITIONS = ( 432 | "DEBUG=1", 433 | "$(inherited)", 434 | ); 435 | INFOPLIST_FILE = PBControllerDemoTests/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PBControllerDemo.app/PBControllerDemo"; 439 | }; 440 | name = Debug; 441 | }; 442 | 58B965031A9B485C00C8E8AD /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | BUNDLE_LOADER = "$(TEST_HOST)"; 446 | FRAMEWORK_SEARCH_PATHS = ( 447 | "$(SDKROOT)/Developer/Library/Frameworks", 448 | "$(inherited)", 449 | ); 450 | INFOPLIST_FILE = PBControllerDemoTests/Info.plist; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PBControllerDemo.app/PBControllerDemo"; 454 | }; 455 | name = Release; 456 | }; 457 | /* End XCBuildConfiguration section */ 458 | 459 | /* Begin XCConfigurationList section */ 460 | 58B964D61A9B485C00C8E8AD /* Build configuration list for PBXProject "PBControllerDemo" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | 58B964FC1A9B485C00C8E8AD /* Debug */, 464 | 58B964FD1A9B485C00C8E8AD /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | 58B964FE1A9B485C00C8E8AD /* Build configuration list for PBXNativeTarget "PBControllerDemo" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 58B964FF1A9B485C00C8E8AD /* Debug */, 473 | 58B965001A9B485C00C8E8AD /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | 58B965011A9B485C00C8E8AD /* Build configuration list for PBXNativeTarget "PBControllerDemoTests" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 58B965021A9B485C00C8E8AD /* Debug */, 482 | 58B965031A9B485C00C8E8AD /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | /* End XCConfigurationList section */ 488 | }; 489 | rootObject = 58B964D31A9B485C00C8E8AD /* Project object */; 490 | } 491 | --------------------------------------------------------------------------------