diff --git a/AutoInsetter.podspec b/AutoInsetter.podspec
index 13916fb..eef4755 100644
--- a/AutoInsetter.podspec
+++ b/AutoInsetter.podspec
@@ -5,7 +5,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.swift_version = "4.0"
- s.version = "1.2.1"
+ s.version = "1.2.2"
s.summary = "Provide auto insetting capabilities to view controllers."
s.description = <<-DESC
Auto Inset engine that can automatically handle custom insetting of view controllers.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a828276..41943d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,12 +3,19 @@ All notable changes to this project will be documented in this file.
`AutoInsetter` adheres to [Semantic Versioning](http://semver.org/).
#### 1.x Releases
-- `1.2.x` Releases - [1.2.0](#120) | [1.2.1](#121)
+- `1.2.x` Releases - [1.2.0](#120) | [1.2.1](#121) | [1.2.2](#122)
- `1.1.x` Releases - [1.1.0](#110)
- `1.0.x` Releases - [1.0.0](#100)
---
+## [1.2.2](https://github.com/uias/AutoInsetter/releases/tag/1.2.2)
+Released on 2018-03-19
+
+#### Fixed
+- Fixed issue where `UITableViewController` and `UICollectionViewController` would not inset correctly.
+ - by [msaps](https://github.com/msaps)
+
## [1.2.1](https://github.com/uias/AutoInsetter/releases/tag/1.2.1)
Released on 2018-02-11
diff --git a/Sources/AutoInsetter/AutoInsetter.swift b/Sources/AutoInsetter/AutoInsetter.swift
index 942ebcf..2deb2f7 100644
--- a/Sources/AutoInsetter/AutoInsetter.swift
+++ b/Sources/AutoInsetter/AutoInsetter.swift
@@ -56,7 +56,7 @@ public final class AutoInsetter {
scrollView.contentInset = requiredContentInset
scrollView.scrollIndicatorInsets = requiredContentInset
-
+
// only update contentOffset if the top contentInset has updated.
if isTopInsetChanged {
var contentOffset = scrollView.contentOffset
@@ -98,10 +98,6 @@ private extension AutoInsetter {
func calculateActualRequiredContentInset(for scrollView: UIScrollView,
from requiredInsetSpec: AutoInsetSpec,
in viewController: UIViewController) -> UIEdgeInsets {
- guard let superview = scrollView.superview else {
- return scrollView.contentInset
- }
-
viewController.view.layoutIfNeeded()
let requiredContentInset = requiredInsetSpec.allRequiredInsets
@@ -112,7 +108,12 @@ private extension AutoInsetter {
if isEmbeddedViewController(viewController) { // Embedded VC is always full canvas
proposedContentInset = requiredContentInset
- } else {
+
+ } else { // Standard View controller
+
+ guard let superview = scrollView.superview else {
+ return scrollView.contentInset
+ }
let relativeFrame = viewController.view.convert(scrollView.frame, from: superview)
let relativeTopInset = max(requiredContentInset.top - relativeFrame.minY, 0.0)
diff --git a/Sources/AutoInsetter/Info.plist b/Sources/AutoInsetter/Info.plist
index c6732b7..3eef9a8 100644
--- a/Sources/AutoInsetter/Info.plist
+++ b/Sources/AutoInsetter/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.2.1
+ 1.2.2
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
NSPrincipalClass