Fixing rotation issues on iphone and ipad when rotating in original view and returning back to story.

This commit is contained in:
Samuel Clay 2015-12-01 15:17:46 -08:00
parent 0117bbc815
commit b756e7cd80
3 changed files with 27 additions and 17 deletions

View file

@ -202,13 +202,13 @@
- (void)showIn:(float)time {
showing = YES;
CGRect frame = self.frame;
frame.size.width = self.view.frame.size.width;
frame.size.width = self.view.bounds.size.width;
self.frame = frame;
self.hidden = NO;
[UIView animateWithDuration:time animations:^{
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y;
move.origin.y = self.view.bounds.size.height - NOTIFIER_HEIGHT - self.offset.y;
self.frame = move;
} completion:nil];
}
@ -223,11 +223,11 @@
- (void)hideIn:(float)seconds {
if (!showing) return;
// if (!showing) return;
[UIView animateWithDuration:seconds animations:^{
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - self.offset.y;
move.origin.y = self.view.bounds.size.height - self.offset.y;
self.frame = move;
} completion:^(BOOL finished) {
self.hidden = YES;

View file

@ -279,6 +279,7 @@
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[self layoutForInterfaceOrientation:orientation];
[self adjustDragBar:orientation];
[self reorientPages];
}
- (void)viewDidAppear:(BOOL)animated {
@ -324,13 +325,14 @@
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
NSLog(@"---> Story page control is re-orienting: %@ / %@", NSStringFromCGSize(self.view.bounds.size), NSStringFromCGSize(size));
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
_orientation = [UIApplication sharedApplication].statusBarOrientation;
[self layoutForInterfaceOrientation:orientation];
[self adjustDragBar:orientation];
[self reorientPages];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
NSLog(@"Story page control did re-orient.");
NSLog(@"---> Story page control did re-orient: %@ / %@", NSStringFromCGSize(self.view.bounds.size), NSStringFromCGSize(size));
}];
}
@ -348,6 +350,13 @@
}
}
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
[self layoutForInterfaceOrientation:orientation];
[self adjustDragBar:orientation];
}
- (void)adjustDragBar:(UIInterfaceOrientation)orientation {
// CGRect scrollViewFrame = self.scrollView.frame;
// CGRect traverseViewFrame = self.traverseView.frame;
@ -436,13 +445,16 @@
[self resizeScrollView]; // Will change currentIndex, so preserve
// Scroll back to preserved index
CGRect frame = self.scrollView.frame;
CGRect frame = self.scrollView.bounds;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
frame = self.view.bounds;
}
frame.origin.x = frame.size.width * currentIndex;
frame.origin.y = 0;
[self.scrollView scrollRectToVisible:frame animated:NO];
NSLog(@"---> Scrolling to story at: %@ %d-%d", NSStringFromCGRect(frame), currentPage.pageIndex, currentIndex);
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.notifier hide];
[self hideNotifier];
}
- (void)refreshHeaders {
@ -461,14 +473,15 @@
[nextPage refreshSideoptions];
[previousPage refreshSideoptions];
}
- (void)resizeScrollView {
NSInteger widthCount = appDelegate.storiesCollection.storyLocationsCount;
if (widthCount == 0) {
widthCount = 1;
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width
* widthCount,
self.scrollView.frame.size.height);
self.scrollView.bounds.size.height);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
@ -533,7 +546,7 @@
pageController.view.hidden = YES;
pageController.view.frame = pageFrame;
}
NSLog(@"---> Story page control orient page: %@ (%d)", NSStringFromCGRect(self.view.bounds), suppressRedraw);
NSLog(@"---> Story page control orient page: %@ (%d-%d)", NSStringFromCGRect(self.view.bounds), pageController.pageIndex, suppressRedraw);
if (suppressRedraw) return;
@ -585,9 +598,6 @@
[pageController clearStory];
}
if (!suppressRedraw) {
[self resizeScrollView];
}
[self setTextButton];
[self.loadingIndicator stopAnimating];
self.circularProgressView.hidden = NO;
@ -759,7 +769,7 @@
}
- (void)setStoryFromScroll:(BOOL)force {
CGFloat pageWidth = self.scrollView.frame.size.width;
CGFloat pageWidth = self.view.bounds.size.width;
float fractionalPage = self.scrollView.contentOffset.x / pageWidth;
NSInteger nearestNumber = lround(fractionalPage);

View file

@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.0.1</string>
<string>5.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -58,7 +58,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>57</string>
<string>58</string>
<key>FacebookAppID</key>
<string>230426707030569</string>
<key>LSApplicationQueriesSchemes</key>