Skip to content

Commit dfe5269

Browse files
committed
- fixed crashes when trying to reload a page that hasn't loaded yet
- preventing blank pages when receving the same view controller instance on reload - bumped version to 2.0.6
1 parent ec56de1 commit dfe5269

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

SCPageViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SCPageViewController'
3-
s.version = '2.0.5'
3+
s.version = '2.0.6'
44
s.platform = :ios
55
s.ios.deployment_target = '5.0'
66

SCPageViewController/SCPageViewController.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,10 @@ - (void)reloadPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated compl
10521052

10531053
[indexes enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger pageIndex, BOOL *stop) {
10541054
UIViewController *oldViewController = [self viewControllerForPageAtIndex:pageIndex];
1055-
[removedViewControllers addObject:oldViewController];
1055+
1056+
if(oldViewController) {
1057+
[removedViewControllers addObject:oldViewController];
1058+
}
10561059

10571060
[oldViewController willMoveToParentViewController:nil];
10581061
if([self.visibleViewControllers containsObject:oldViewController]) {
@@ -1061,6 +1064,10 @@ - (void)reloadPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated compl
10611064

10621065
[self.pages replaceObjectAtIndex:pageIndex withObject:[NSNull null]];
10631066
UIViewController *newViewController = [self _createAndInsertNewPageAtIndex:pageIndex];
1067+
1068+
if([newViewController isEqual:oldViewController]) {
1069+
[removedViewControllers removeObject:newViewController];
1070+
}
10641071

10651072
if(animated && [self.layouter respondsToSelector:@selector(animatePageReloadAtIndex:oldViewController:newViewController:pageViewController:completion:)]) {
10661073
dispatch_group_enter(animationsDispatchGroup);

0 commit comments

Comments
 (0)