diff --git a/JASidePanels.podspec b/JASidePanels.podspec new file mode 100644 index 0000000..be93561 --- /dev/null +++ b/JASidePanels.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'JASidePanels' + s.version = '1.3.2' + s.license = { :type => 'MIT', :file => 'README.markdown' } + s.summary = 'UIViewController container designed for presenting a center panel with revealable side panels - one to the left and one to the right.' + s.homepage = 'https://github.com/gotosleep/JASidePanels' + s.author = { 'Jesse Andersen' => 'gotosleep@gmail.com' } + s.source = { :git => 'https://github.com/gotosleep/JASidePanels.git', :tag => '1.3.2' } + s.platform = :ios, '5.0' + s.source_files = 'JASidePanels/Source/*' + s.framework = 'QuartzCore' + s.requires_arc = true +end diff --git a/JASidePanels/Source/JASidePanelController.m b/JASidePanels/Source/JASidePanelController.m index 7cfde70..581aa5e 100644 --- a/JASidePanels/Source/JASidePanelController.m +++ b/JASidePanels/Source/JASidePanelController.m @@ -192,28 +192,6 @@ - (void)viewDidAppear:(BOOL)animated{ [self _adjustCenterFrame]; //Account for possible rotation while view appearing } -#if !defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 - -- (void)viewDidUnload { - [super viewDidUnload]; - self.tapView = nil; - self.centerPanelContainer = nil; - self.leftPanelContainer = nil; - self.rightPanelContainer = nil; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - __strong UIViewController *visiblePanel = self.visiblePanel; - - if (self.shouldDelegateAutorotateToVisiblePanel) { - return [visiblePanel shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; - } else { - return YES; - } -} - -#else - - (BOOL)shouldAutorotate { __strong UIViewController *visiblePanel = self.visiblePanel; @@ -224,19 +202,11 @@ - (BOOL)shouldAutorotate { } } - -#endif - -- (void)willAnimateRotationToInterfaceOrientation:(__unused UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - self.centerPanelContainer.frame = [self _adjustCenterFrame]; - [self _layoutSideContainers:YES duration:duration]; - [self _layoutSidePanels]; - [self styleContainer:self.centerPanelContainer animate:YES duration:duration]; - if (self.centerPanelHidden) { - CGRect frame = self.centerPanelContainer.frame; - frame.origin.x = self.state == JASidePanelLeftVisible ? self.centerPanelContainer.frame.size.width : -self.centerPanelContainer.frame.size.width; - self.centerPanelContainer.frame = frame; - } +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self styleContainer:self.centerPanelContainer animate:YES duration:0]; + }); } #pragma mark - State @@ -370,11 +340,11 @@ - (void)setCenterPanel:(UIViewController *)centerPanel { if (self.bounceOnCenterPanelChange) { // first move the centerPanel offscreen CGFloat x = (previousState == JASidePanelLeftVisible) ? self.view.bounds.size.width : -self.view.bounds.size.width; - _centerPanelRestingFrame.origin.x = x; + self->_centerPanelRestingFrame.origin.x = x; } - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; } completion:^(__unused BOOL finished) { - [self _swapCenter:previous previousState:previousState with:_centerPanel]; + [self _swapCenter:previous previousState:previousState with:self->_centerPanel]; [self _showCenterPanel:YES bounce:NO]; }]; } @@ -463,7 +433,7 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if (translate.x > 0 && ! self.allowLeftSwipe) { return NO; } - BOOL possible = translate.x != 0 && ((fabsf(translate.y) / fabsf(translate.x)) < 1.0f); + BOOL possible = translate.x != 0 && ((fabs(translate.y) / fabs(translate.x)) < 1.0f); if (possible && ((translate.x > 0 && self.leftPanel) || (translate.x < 0 && self.rightPanel))) { return YES; } @@ -609,8 +579,6 @@ - (CGFloat)_correctMovement:(CGFloat)movement { } else if (self.state == JASidePanelRightVisible && !self.allowRightOverpan) { if (position < -self.rightVisibleWidth) { return 0.0f; - } else if ((self.style == JASidePanelMultipleActive || self.pushesSidePanels) && position > 0.0f) { - return -_centerPanelRestingFrame.origin.x; } else if (position > self.rightPanelContainer.frame.origin.x) { return self.rightPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x; } @@ -633,7 +601,7 @@ - (BOOL)_validateThreshold:(CGFloat)movement { return movement <= -minimum; } case JASidePanelCenterVisible: { - return fabsf(movement) >= minimum; + return fabs(movement) >= minimum; } case JASidePanelRightVisible: { return movement >= minimum; @@ -726,8 +694,8 @@ - (void)_unloadPanels { #pragma mark - Animation - (CGFloat)_calculatedDuration { - CGFloat remaining = fabsf(self.centerPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x); - CGFloat max = _locationBeforePan.x == _centerPanelRestingFrame.origin.x ? remaining : fabsf(_locationBeforePan.x - _centerPanelRestingFrame.origin.x); + CGFloat remaining = fabs(self.centerPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x); + CGFloat max = _locationBeforePan.x == _centerPanelRestingFrame.origin.x ? remaining : fabs(_locationBeforePan.x - _centerPanelRestingFrame.origin.x); return max > 0.0f ? self.maximumAnimationDuration * (remaining / max) : self.maximumAnimationDuration; } @@ -741,7 +709,7 @@ - (void)_animateCenterPanel:(BOOL)shouldBounce completion:(void (^)(BOOL finishe CGFloat duration = [self _calculatedDuration]; [UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionLayoutSubviews animations:^{ - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; [self styleContainer:self.centerPanelContainer animate:YES duration:duration]; if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) { [self _layoutSideContainers:NO duration:0.0f]; @@ -758,12 +726,12 @@ - (void)_animateCenterPanel:(BOOL)shouldBounce completion:(void (^)(BOOL finishe } // animate the bounce [UIView animateWithDuration:self.bounceDuration delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{ - CGRect bounceFrame = _centerPanelRestingFrame; + CGRect bounceFrame = self->_centerPanelRestingFrame; bounceFrame.origin.x += bounceDistance; self.centerPanelContainer.frame = bounceFrame; } completion:^(__unused BOOL finished2) { [UIView animateWithDuration:self.bounceDuration delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{ - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; } completion:completion]; }]; } else if (completion) { @@ -1020,7 +988,7 @@ - (void)setCenterPanelHidden:(BOOL)centerPanelHidden animated:(BOOL)animated dur } } completion:^(__unused BOOL finished) { // need to double check in case the user tapped really fast - if (_centerPanelHidden) { + if (self->_centerPanelHidden) { [self _hideCenterPanel]; } }];