Skip to content

Commit

Permalink
Merge pull request #191 from algrid/fix-149
Browse files Browse the repository at this point in the history
Handle device orientation change in layoutSubviews instead of notif-n
  • Loading branch information
ealeksandrov authored Nov 5, 2016
2 parents b16b022 + fb776dc commit 5bca5fe
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions EAIntroView/EAIntroView.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,6 @@ - (void)notifyDelegateWithPreviousPage:(NSUInteger)previousPageIndex andCurrentP
}
}

-(void)willMoveToSuperview:(UIView *)newSuperview {
[super willMoveToSuperview:newSuperview];
if (self.superview == nil && newSuperview != nil) {
// Add observer for device orientation:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(deviceOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
} else if (self.superview != nil && newSuperview == nil) {
// Remove observer for rotation
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
}

#pragma mark - Properties

- (EARestrictedScrollView *)scrollView {
Expand Down Expand Up @@ -674,9 +658,11 @@ - (void)crossDissolveForOffset:(CGFloat)offset {
}
}

#pragma mark - Notifications
#pragma mark - UIView lifecycle calls

- (void)layoutSubviews {
[super layoutSubviews];

- (void)deviceOrientationDidChange:(NSNotification *)notification {
// Get amount of pages:
NSInteger numberOfPages = _pages.count;

Expand Down

0 comments on commit 5bca5fe

Please sign in to comment.