Skip to content

Commit

Permalink
Merge pull request #188 from uias/feature/memory-fix
Browse files Browse the repository at this point in the history
Fix some memory / threading issues
  • Loading branch information
msaps authored Dec 1, 2018
2 parents cdabf60 + 33fbca3 commit e4208f6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 88 deletions.
6 changes: 0 additions & 6 deletions Sources/Pageboy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
464ADF5F20975E5000929AFB /* UIViewController+Pageboy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 464ADF5E20975E5000929AFB /* UIViewController+Pageboy.swift */; };
464ADF6020975E5000929AFB /* UIViewController+Pageboy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 464ADF5E20975E5000929AFB /* UIViewController+Pageboy.swift */; };
466A76B61FB38B32000B5C1C /* PageboyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D623B1D11E1D2DF200527F3D /* PageboyViewController.swift */; };
468B6FC020EF66A30038E26C /* ScrollObservationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 468B6FBF20EF66A30038E26C /* ScrollObservationService.swift */; };
468B6FC120EF66A30038E26C /* ScrollObservationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 468B6FBF20EF66A30038E26C /* ScrollObservationService.swift */; };
46ADAAB6208F7E1500974529 /* PageboyAutoScroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ADAAB4208F7E1500974529 /* PageboyAutoScroller.swift */; };
46ADAAB7208F7E1500974529 /* PageboyAutoScroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ADAAB4208F7E1500974529 /* PageboyAutoScroller.swift */; };
46ADAAB8208F7E1500974529 /* PageboyViewController+AutoScrolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ADAAB5208F7E1500974529 /* PageboyViewController+AutoScrolling.swift */; };
Expand Down Expand Up @@ -87,7 +85,6 @@
464ADF5820975E3D00929AFB /* PageboyViewControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyViewControllerDelegate.swift; sourceTree = "<group>"; };
464ADF5920975E3D00929AFB /* PageboyViewControllerDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyViewControllerDataSource.swift; sourceTree = "<group>"; };
464ADF5E20975E5000929AFB /* UIViewController+Pageboy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Pageboy.swift"; sourceTree = "<group>"; };
468B6FBF20EF66A30038E26C /* ScrollObservationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollObservationService.swift; sourceTree = "<group>"; };
46ADAAB4208F7E1500974529 /* PageboyAutoScroller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageboyAutoScroller.swift; sourceTree = "<group>"; };
46ADAAB5208F7E1500974529 /* PageboyViewController+AutoScrolling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+AutoScrolling.swift"; sourceTree = "<group>"; };
46ADAABB208F7E8500974529 /* PageboyViewController+Transitioning.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PageboyViewController+Transitioning.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -271,7 +268,6 @@
isa = PBXGroup;
children = (
462A65D82000FCAA0051C79C /* Extensions */,
468B6FBF20EF66A30038E26C /* ScrollObservationService.swift */,
);
path = Utilities;
sourceTree = "<group>";
Expand Down Expand Up @@ -485,7 +481,6 @@
46ADAAB6208F7E1500974529 /* PageboyAutoScroller.swift in Sources */,
464ADF552097565D00929AFB /* Page.swift in Sources */,
46ADAAB8208F7E1500974529 /* PageboyViewController+AutoScrolling.swift in Sources */,
468B6FC020EF66A30038E26C /* ScrollObservationService.swift in Sources */,
462A65E32000FCAA0051C79C /* UIPageViewController+ScrollView.swift in Sources */,
46ADAAC2208F7E8500974529 /* TransitionOperation.swift in Sources */,
461D6DF1201795A100E0CDEE /* UIScrollView+ScrollActivity.swift in Sources */,
Expand Down Expand Up @@ -531,7 +526,6 @@
46ADAAB7208F7E1500974529 /* PageboyAutoScroller.swift in Sources */,
464ADF562097565D00929AFB /* Page.swift in Sources */,
46ADAAB9208F7E1500974529 /* PageboyViewController+AutoScrolling.swift in Sources */,
468B6FC120EF66A30038E26C /* ScrollObservationService.swift in Sources */,
462A65E42000FCAA0051C79C /* UIPageViewController+ScrollView.swift in Sources */,
461D6DF2201795A100E0CDEE /* UIScrollView+ScrollActivity.swift in Sources */,
46ADAAC3208F7E8500974529 /* TransitionOperation.swift in Sources */,
Expand Down
5 changes: 4 additions & 1 deletion Sources/Pageboy/PageboyViewController+Management.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ internal extension PageboyViewController {

// if not using a custom transition then animate using UIPageViewController mechanism
let animateUpdate = animated ? !isUsingCustomTransition : false
let updateBlock = { [unowned self] in
let updateBlock = { [weak self] in
guard let self = self else {
return
}
pageViewController.setViewControllers(viewControllers,
direction: direction.layoutNormalized(isRtL: self.view.layoutIsRightToLeft).rawValue,
animated: animateUpdate,
Expand Down
15 changes: 12 additions & 3 deletions Sources/Pageboy/Utilities/Extensions/UIView+Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ extension UIView {

/// Whether the layout direction of the view is right to left.
var layoutIsRightToLeft: Bool {
if #available(iOS 9.0, *) {
return UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft
var layoutDirection: UIUserInterfaceLayoutDirection!
if Thread.isMainThread {
layoutDirection = getUserInterfaceLayoutDirection()
} else {
return UIApplication.safeShared?.userInterfaceLayoutDirection == .rightToLeft
DispatchQueue.main.sync {
layoutDirection = getUserInterfaceLayoutDirection()
}
}
return layoutDirection == .rightToLeft
}

private func getUserInterfaceLayoutDirection() -> UIUserInterfaceLayoutDirection {
assert(Thread.isMainThread)
return UIView.userInterfaceLayoutDirection(for: semanticContentAttribute)
}

}
78 changes: 0 additions & 78 deletions Sources/Pageboy/Utilities/ScrollObservationService.swift

This file was deleted.

0 comments on commit e4208f6

Please sign in to comment.