Skip to content

Instantly share code, notes, and snippets.

@dral3x
Created January 24, 2015 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dral3x/8eafd084bc8775146a5a to your computer and use it in GitHub Desktop.
Save dral3x/8eafd084bc8775146a5a to your computer and use it in GitHub Desktop.
Subclass of UIPageViewController that fix the Alzheimer bug
#import <UIKit/UIKit.h>
@interface SPKPageViewController : UIPageViewController
@end
#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