diff --git a/.gitignore b/.gitignore index 47042c2..16703a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,23 @@ +# OS X .DS_Store + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 xcuserdata +*.xccheckout +profile +*.moved-aside +DerivedData +*.hmap +*.ipa + +# CocoaPods +Pods \ No newline at end of file diff --git a/BDBSplitViewController/BDBSplitViewController.m b/BDBSplitViewController/BDBSplitViewController.m index 06108ec..b50b887 100644 --- a/BDBSplitViewController/BDBSplitViewController.m +++ b/BDBSplitViewController/BDBSplitViewController.m @@ -99,6 +99,12 @@ - (id)initWithMasterViewController:(UIViewController *)mvc detailViewController: return self; } +- (void)dealloc +{ + //Remove the observer to avoid KVO informations leakage error (NSKVODeallocateBreak) + [self.detailViewController removeObserver:self forKeyPath:@"view.frame" context:kBDBSplitViewKVOContext]; +} + - (void)awakeFromNib { [super awakeFromNib]; @@ -139,13 +145,16 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if ([object isEqual:self.detailViewController] && [keyPath isEqualToString:@"view.frame"]) + if (context == kBDBSplitViewKVOContext) { - UIView *view = self.detailViewController.view; - CGRect currentFrame = [change[@"new"] CGRectValue]; - CGRect properFrame = [self detailViewFrameForState:self.masterViewState]; - if (!CGRectEqualToRect(currentFrame, properFrame)) - view.frame = [self detailViewFrameForState:self.masterViewState]; + if ([object isEqual:self.detailViewController] && [keyPath isEqualToString:@"view.frame"]) + { + UIView *view = self.detailViewController.view; + CGRect currentFrame = [change[@"new"] CGRectValue]; + CGRect properFrame = [self detailViewFrameForState:self.masterViewState]; + if (!CGRectEqualToRect(currentFrame, properFrame)) + view.frame = [self detailViewFrameForState:self.masterViewState]; + } } else [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];