From c57ef3abd14c6d20a88d00d9121df87ff493da0a Mon Sep 17 00:00:00 2001 From: Vasyl Myronchuk Date: Tue, 23 Jul 2013 15:10:54 +0300 Subject: [PATCH] Added possibility for more fine-grained layout control in subclasses. --- .../CLFContainerViewController.h | 6 +++++- .../CLFContainerViewController.m | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CLFContainerViewController/CLFContainerViewController.h b/CLFContainerViewController/CLFContainerViewController.h index e347cfe..c0ae863 100644 --- a/CLFContainerViewController/CLFContainerViewController.h +++ b/CLFContainerViewController/CLFContainerViewController.h @@ -83,9 +83,13 @@ // This property determines the frame that will be used for child view controllers in a non-transitioning state. Unless -// overriden by your subclass it will return self.view.bounds +// overriden by your subclass it will return self.containerView.bounds @property (readonly, nonatomic) CGRect childRestingFrame; +// This property determines the view into which child view controller's view should be inserted as subview. +// This could be convenient if container controller manages somewhat complex layout. +// Unless overriden by your subclass is self.view +@property (readonly, nonatomic) UIView *containerView; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - Properties that should only be used by subclasses diff --git a/CLFContainerViewController/CLFContainerViewController.m b/CLFContainerViewController/CLFContainerViewController.m index aa40791..9354d9e 100644 --- a/CLFContainerViewController/CLFContainerViewController.m +++ b/CLFContainerViewController/CLFContainerViewController.m @@ -159,9 +159,13 @@ - (void)dealloc - (CGRect)childRestingFrame { - return self.view.bounds; + return self.containerView.bounds; } +- (UIView *)containerView +{ + return self.view; +} - (void (^)())rotationInterruptionCleanupBlock { @@ -379,7 +383,7 @@ - (void)registerTransitionFromViewController:(UIViewController *)fromViewControl if (![self.childViewControllers containsObject:toViewController]) [self addChildViewController:toViewController]; - if (![self.view.subviews containsObject:toViewController.view]) + if (![self.containerView.subviews containsObject:toViewController.view]) [self addViewFromViewController:toViewController]; } @@ -412,7 +416,7 @@ - (void)addViewFromViewController:(UIViewController *)viewController view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - [self.view insertSubview:view atIndex:0]; + [self.containerView insertSubview:view atIndex:0]; }