diff --git a/SwipeView/SwipeView.h b/SwipeView/SwipeView.h index 2fb12dd..f75dee5 100755 --- a/SwipeView/SwipeView.h +++ b/SwipeView/SwipeView.h @@ -122,6 +122,22 @@ typedef NS_ENUM(NSUInteger, SwipeViewAlignment) - (BOOL)swipeView:(SwipeView *)swipeView shouldSelectItemAtIndex:(NSInteger)index; - (void)swipeView:(SwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index; +//These method gives you the overrides you need to have the subviews controlled by a UIViewController +//Presumably you will call -[willMoveToParentViewController:nil] +- (void)swipeView:(SwipeView *)swipeView willRemoveSubview:(UIView *)view forItemAtIndex:(NSInteger)index; + +//These method gives you the overrides you need to have the subviews controlled by a UIViewController +//Presumably you will call -[removeFromParentViewController] +- (void)swipeView:(SwipeView *)swipeView didRemoveSubview:(UIView *)view forItemAtIndex:(NSInteger)index; + +//These method gives you the overrides you need to have the subviews controlled by a UIViewController +//Presumably you will call -[addChildViewController:] +- (void)swipeView:(SwipeView *)swipeView willAddSubview:(UIView *)view forItemAtIndex:(NSInteger)index; + +//These method gives you the overrides you need to have the subviews controlled by a UIViewController +//Presumably you will call -[didMoveToParentViewController:] +- (void)swipeView:(SwipeView *)swipeView didAddSubview:(UIView *)view forItemAtIndex:(NSInteger)index; + @end diff --git a/SwipeView/SwipeView.m b/SwipeView/SwipeView.m index 04e942b..0fb8ad8 100755 --- a/SwipeView/SwipeView.m +++ b/SwipeView/SwipeView.m @@ -896,7 +896,16 @@ - (UIView *)loadViewAtIndex:(NSInteger)index [self setItemView:view forIndex:index]; [self setFrameForView:view atIndex:index]; view.userInteractionEnabled = YES; + + if (_delegate && [_delegate respondsToSelector:@selector(swipeView:willAddSubview:forItemAtIndex:)]) + { + [self.delegate swipeView:self willAddSubview:oldView forItemAtIndex:index]; + } [_scrollView addSubview:view]; + if (_delegate && [_delegate respondsToSelector:@selector(swipeView:didAddSubview:forItemAtIndex:)]) + { + [self.delegate swipeView:self didAddSubview:oldView forItemAtIndex:index]; + } return view; } @@ -959,7 +968,15 @@ - (void)loadUnloadViews { UIView *view = _itemViews[number]; [self queueItemView:view]; + if (_delegate && [_delegate respondsToSelector:@selector(swipeView:willRemoveSubview:forItemAtIndex:)]) + { + [self.delegate swipeView:self willRemoveSubview:view forItemAtIndex:number.integerValue]; + } [view removeFromSuperview]; + if (_delegate && [_delegate respondsToSelector:@selector(swipeView:didRemoveSubview:forItemAtIndex:)]) + { + [self.delegate swipeView:self didRemoveSubview:view forItemAtIndex:number.integerValue]; + } [_itemViews removeObjectForKey:number]; } }