From dfa4119cf38e752ce86d40864c7c51bb455bd284 Mon Sep 17 00:00:00 2001 From: Ricki Gregersen Date: Sun, 30 Mar 2014 15:17:03 +0200 Subject: [PATCH 1/2] Exposed the initPages method in the header file. --- GRKPageViewController/GRKPageViewController.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GRKPageViewController/GRKPageViewController.h b/GRKPageViewController/GRKPageViewController.h index 5f5fc0d..d90c19c 100644 --- a/GRKPageViewController/GRKPageViewController.h +++ b/GRKPageViewController/GRKPageViewController.h @@ -89,4 +89,12 @@ */ - (void)setCurrentIndex:(NSUInteger)index animated:(BOOL)animated; +/** + If you change the count of viewControllers, call this method to recalculate the + scrollView content size. + e.g. PageViewController is added to the screen upon viewHiearchy setup, but your data + is coming in asynchronously. + */ +- (void)initPages; + @end From b48a13a0b448f0e179371763631f4374932638f7 Mon Sep 17 00:00:00 2001 From: Ricki Gregersen Date: Sun, 30 Mar 2014 15:32:30 +0200 Subject: [PATCH 2/2] Removed initPages from interface and wrapped it in updatePageLayout() --- GRKPageViewController/GRKPageViewController.h | 4 ++-- GRKPageViewController/GRKPageViewController.m | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GRKPageViewController/GRKPageViewController.h b/GRKPageViewController/GRKPageViewController.h index d90c19c..77d745f 100644 --- a/GRKPageViewController/GRKPageViewController.h +++ b/GRKPageViewController/GRKPageViewController.h @@ -90,11 +90,11 @@ - (void)setCurrentIndex:(NSUInteger)index animated:(BOOL)animated; /** - If you change the count of viewControllers, call this method to recalculate the + If you change the count of viewControllers after viewDidLoad, call this method to recalculate the scrollView content size. e.g. PageViewController is added to the screen upon viewHiearchy setup, but your data is coming in asynchronously. */ -- (void)initPages; +- (void) updatePageLayout; @end diff --git a/GRKPageViewController/GRKPageViewController.m b/GRKPageViewController/GRKPageViewController.m index da3bd26..34457ce 100644 --- a/GRKPageViewController/GRKPageViewController.m +++ b/GRKPageViewController/GRKPageViewController.m @@ -91,6 +91,11 @@ - (void)initPages #pragma mark - Acessors +- (void) updatePageLayout +{ + [self initPages]; +} + - (void)setCurrentIndex:(NSUInteger)currentIndex { [self setCurrentIndex:currentIndex animated:NO];