Skip to content

Commit

Permalink
Merge pull request #27 from deliveryhero/bugfix/fix-retain-cycle-with…
Browse files Browse the repository at this point in the history
…-containerVC-and-delegate

Fix retain cycle with containerVC and delegate
  • Loading branch information
hanynady authored Jun 17, 2020
2 parents 96c5546 + 6b11ef9 commit 667c41e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Sources/ParallaxPagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public final class ParallaxPagerView: UIView {

private let scaleHeaderOnBounce: Bool

private var parallaxDelegate: ParallaxViewDelegate?
private weak var parallaxDelegate: ParallaxViewDelegate?
private var pagerDelegate: PagerDelegate?

private var contentOffsetObservation: NSKeyValueObservation?
private var contentInsetObservation: NSKeyValueObservation?

private let containerViewController: UIViewController
private weak var containerViewController: UIViewController?

private var headerHeightConstraint: NSLayoutConstraint?
private var contentViewLeadingConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -224,8 +224,8 @@ public final class ParallaxPagerView: UIView {

layoutInternalScrollView()

containerViewController.automaticallyAdjustsScrollViewInsets = false
containerViewController.extendedLayoutIncludesOpaqueBars = false
containerViewController?.automaticallyAdjustsScrollViewInsets = false
containerViewController?.extendedLayoutIncludesOpaqueBars = false
preservesSuperviewLayoutMargins = true

headerView.clipsToBounds = true
Expand Down Expand Up @@ -505,7 +505,7 @@ public final class ParallaxPagerView: UIView {

vc.willMove(toParent: containerViewController)
internalScrollView.insertSubview(vc.view, at: 0)
containerViewController.addChild(vc)
containerViewController?.addChild(vc)
vc.didMove(toParent: containerViewController)

contentViewTrailingConstraint = NSLayoutConstraint(
Expand Down
2 changes: 1 addition & 1 deletion Sources/Protocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol ParallaxContentViewController {
func scrollableView() -> UIScrollView?
}

public protocol ParallaxViewDelegate {
public protocol ParallaxViewDelegate: AnyObject {
func parallaxViewDidScrollBy(percentage: CGFloat, oldOffset: CGPoint, newOffset: CGPoint)
}

Expand Down

0 comments on commit 667c41e

Please sign in to comment.