Skip to content
Permalink
Browse files

[Sources] [RSKGrowingTextView] Handle `UITextView.textDidChangeNotifi…

…cation`.

Fixes #18.
  • Loading branch information...
ruslanskorb committed Jul 18, 2019
1 parent 11d40da commit 86d60c1a21033d4fa575fd6fbe83482d5061c4a7
Showing with 14 additions and 0 deletions.
  1. +14 −0 RSKGrowingTextView/RSKGrowingTextView.swift
@@ -180,6 +180,11 @@ public typealias HeightChangeUserActionsBlockType = ((_ oldHeight: CGFloat, _ ne

// MARK: - Object Lifecycle
deinit {

NotificationCenter.default.removeObserver(self, name: UITextView.textDidChangeNotification, object: self)
}

required public init?(coder aDecoder: NSCoder) {
calculationLayoutManager.addTextContainer(calculationTextContainer)
super.init(coder: aDecoder)
@@ -192,6 +197,13 @@ public typealias HeightChangeUserActionsBlockType = ((_ oldHeight: CGFloat, _ ne
commonInitializer()
}

// MARK: - Actions
@objc private func handleRSKGrowingTextViewTextDidChangeNotification(_ notification: Notification) {

refreshHeightIfNeededAnimated(animateHeightChange)
}

// MARK: - Private API
private func commonInitializer() {
@@ -206,6 +218,8 @@ public typealias HeightChangeUserActionsBlockType = ((_ oldHeight: CGFloat, _ ne
break
}
}

NotificationCenter.default.addObserver(self, selector: #selector(RSKGrowingTextView.handleRSKGrowingTextViewTextDidChangeNotification(_:)), name: UITextView.textDidChangeNotification, object: self)
}

private func heightForNumberOfLines(_ numberOfLines: Int) -> CGFloat {

0 comments on commit 86d60c1

Please sign in to comment.
You can’t perform that action at this time.