iOS: fixed #774 (story page position after activating)

Now re-activates without story page glitches, and handles rotation
while inactive properly.
This commit is contained in:
David Sinclair 2015-11-02 21:09:17 -08:00
parent 5e4f7d27c5
commit 839a1d0417

View file

@ -57,6 +57,7 @@
@property (readwrite) BOOL feedDetailIsVisible;
@property (readwrite) BOOL keyboardIsShown;
@property (readwrite) UIDeviceOrientation rotatingToOrientation;
@property (nonatomic) UIBackgroundTaskIdentifier reorientBackgroundTask;
@property (nonatomic, strong) UIPopoverController *popoverController;
@ -222,11 +223,26 @@
[self layoutFeedDetailScreen];
}
if (self.feedDetailIsVisible) {
[self.storyPageControl reorientPages];
// Defer this in the background, to avoid misaligning the detail views
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
self.reorientBackgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:self.reorientBackgroundTask];
self.reorientBackgroundTask = UIBackgroundTaskInvalid;
}];
[self performSelector:@selector(delayedReorientPages) withObject:nil afterDelay:0.5];
} else {
[self.storyPageControl reorientPages];
}
}
}];
}
- (void)delayedReorientPages {
[self.storyPageControl reorientPages];
[[UIApplication sharedApplication] endBackgroundTask:self.reorientBackgroundTask];
self.reorientBackgroundTask = UIBackgroundTaskInvalid;
}
- (NSInteger)masterWidth {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {