Created
January 24, 2015 09:23
-
-
Save dral3x/8eafd084bc8775146a5a to your computer and use it in GitHub Desktop.
Subclass of UIPageViewController that fix the Alzheimer bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface SPKPageViewController : UIPageViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "SPKPageViewController.h" | |
@implementation SPKPageViewController | |
- (void)setViewControllers:(NSArray *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL finished))completion | |
{ | |
__block typeof(self) bSelf = self; | |
[super setViewControllers:viewControllers | |
direction:direction | |
animated:animated | |
completion:^(BOOL finished) { | |
// FIX: bug fix for UIPageViewController | |
// http://stackoverflow.com/a/17330606/839233 | |
// On iOS8 this bug seams to be resolved | |
if (animated && finished) { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[bSelf setViewControllers:viewControllers | |
direction:direction | |
animated:NO | |
completion:completion]; | |
}); | |
} | |
else { | |
if (completion) { | |
completion(finished); | |
} | |
} | |
}]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment