Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into swift4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodebortoli committed Dec 4, 2018
2 parents b13ef1f + 06469f8 commit 6579fc4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
@@ -1,5 +1,5 @@
PODS:
- ScrollingStackViewController (4.0.0)
- ScrollingStackViewController (4.0.1)

DEPENDENCIES:
- ScrollingStackViewController (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
ScrollingStackViewController: c87977311c6e8b0c4d32fcf9530dd60250d9c470
ScrollingStackViewController: ae954d22a57508749a58c5ffb01231a8dba2817d

PODFILE CHECKSUM: 1107023c97aaa6562f2eb38595e37b1267bba2b1

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Example/Tests/ScrollingStackViewTests.swift
Expand Up @@ -59,6 +59,28 @@ class ScrollingStackViewTests: XCTestCase {
vc.remove(viewController: child2)
XCTAssert(vc.stackView.arrangedSubviews.count == 1)
}

func testRemoveViewControllers() {
let vc = Factory.createScrollingStackViewController(window: window)
let height = vc.view.frame.height

let arrangedVC = Factory.createStubViewController(height: height)
let containedVC = Factory.createStubViewController(height: height)
let edgeInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

vc.add(viewController: arrangedVC)
vc.show(viewController: arrangedVC)
vc.show(viewController: containedVC, insertIfNeeded: (position: .end, insets: edgeInset))
XCTAssert(vc.stackView.arrangedSubviews.count == 2)

vc.remove(viewController: arrangedVC)
XCTAssert(vc.stackView.arrangedSubviews.count == 1)
XCTAssert(arrangedVC.view.superview == nil)

vc.remove(viewController: containedVC)
XCTAssert(vc.stackView.arrangedSubviews.count == 0)
XCTAssert(containedVC.view.superview == nil)
}

func testComplexScrolling() {

Expand Down
2 changes: 1 addition & 1 deletion ScrollingStackViewController.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ScrollingStackViewController'
s.version = '4.0.0'
s.version = '4.0.1'
s.summary = 'A view controller that uses root views of child view controllers as views in a UIStackView.'

s.description = <<-DESC
Expand Down
Expand Up @@ -207,10 +207,12 @@ open class ScrollingStackViewController: UIViewController {

open func remove(viewController: UIViewController) {
guard let arrangedView = arrangedView(for: viewController) else { return }
stackView.removeArrangedSubview(arrangedView)

viewController.willMove(toParent: nil)
arrangedView.removeFromSuperview()
if arrangedView != viewController.view {
viewController.view.removeFromSuperview()
}

viewController.willMove(toParent: nil)
viewController.removeFromParent()
}

Expand Down

0 comments on commit 6579fc4

Please sign in to comment.