Skip to content

Commit

Permalink
Merge pull request #84 from Orderella/development
Browse files Browse the repository at this point in the history
Fixes memory leak with custom view controllers
  • Loading branch information
mwfire committed Jan 1, 2017
2 parents ed3846e + b01553f commit 44e04bd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

* **0.5.3** Fixed memory leak with custom view controllers
* **0.5.2** Fixed image scaling for default view
* **0.5.1** Introduced custom button height parameter<br>Reintroduced iOS8 compatibility
* **0.5.0** Swift 3 compatibility / removed iOS8
Expand Down
2 changes: 1 addition & 1 deletion PopupDialog.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PopupDialog'
s.version = '0.5.2'
s.version = '0.5.3'
s.summary = 'A simple custom popup dialog view controller'
s.homepage = 'https://github.com/orderella/PopupDialog'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
13 changes: 1 addition & 12 deletions PopupDialog/Classes/InteractiveTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@

import Foundation

protocol InteractiveTransitionDelegate {
func interactiveTransitionDidDismissViewController()
}

// Handles interactive transition triggered via pan gesture recognizer on dialog
final internal class InteractiveTransition: UIPercentDrivenInteractiveTransition {

var delegate: InteractiveTransitionDelegate?

// If the interactive transition was started
var hasStarted = false

Expand Down Expand Up @@ -63,12 +57,7 @@ final internal class InteractiveTransition: UIPercentDrivenInteractiveTransition
case .ended:
hasStarted = false
completionSpeed = 0.55
if shouldFinish {
finish()
delegate?.interactiveTransitionDidDismissViewController()
} else {
cancel()
}
shouldFinish ? finish() : cancel()
default:
break
}
Expand Down
14 changes: 3 additions & 11 deletions PopupDialog/Classes/PopupDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Foundation
import UIKit

/// Creates a Popup dialog similar to UIAlertController
final public class PopupDialog: UIViewController, InteractiveTransitionDelegate {
final public class PopupDialog: UIViewController {

// MARK: Private / Internal

Expand All @@ -41,11 +41,7 @@ final public class PopupDialog: UIViewController, InteractiveTransitionDelegate
fileprivate var presentationManager: PresentationManager!

/// Interactor class for pan gesture dismissal
fileprivate lazy var interactor: InteractiveTransition = {
let interactor = InteractiveTransition()
interactor.delegate = self
return interactor
}()
fileprivate lazy var interactor = InteractiveTransition()

/// Returns the controllers view
internal var popupContainerView: PopupDialogContainerView {
Expand Down Expand Up @@ -204,11 +200,7 @@ final public class PopupDialog: UIViewController, InteractiveTransitionDelegate
// Make sure it's not a tap on the dialog but the background
let point = sender.location(in: popupContainerView.stackView)
guard !popupContainerView.stackView.point(inside: point, with: nil) else { return }
dismiss(self.completion)
}

func interactiveTransitionDidDismissViewController() {
self.completion?()
dismiss()
}

/*!
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ Minimum requirement is iOS 8.0. This dialog was written with Swift 3, for 2.2 co
# Changelog
* **0.5.3** Fixed memory leak with custom view controllers
* **0.5.2** Fixed image scaling for default view
* **0.5.1** Introduced custom button height parameter<br>Reintroduced iOS8 compatibility
* **0.5.0** Swift 3 compatibility / removed iOS8
Expand Down

0 comments on commit 44e04bd

Please sign in to comment.