Skip to content

Commit 451321f

Browse files
committed
FIX: autolayout conflict.
FIX: new constant variables in Swift 4.2
1 parent 3829347 commit 451321f

7 files changed

Lines changed: 31 additions & 17 deletions

File tree

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

Example/GrowingTextView/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

Example/GrowingTextView/Base.lproj/Main.storyboard

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fnq-Oa-kwt">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fnq-Oa-kwt">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment version="2304" identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
99
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -124,10 +124,10 @@
124124
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
125125
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
126126
<subviews>
127-
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
127+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
128128
<rect key="frame" x="0.0" y="618" width="375" height="49"/>
129129
<subviews>
130-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
130+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
131131
<rect key="frame" x="8" y="8" width="359" height="33"/>
132132
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
133133
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -148,7 +148,7 @@
148148
</subviews>
149149
<color key="backgroundColor" white="0.92000000000000004" alpha="1" colorSpace="calibratedWhite"/>
150150
<constraints>
151-
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" constant="8" id="8cx-hM-mDY"/>
151+
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" priority="999" constant="8" id="8cx-hM-mDY"/>
152152
</constraints>
153153
</view>
154154
</subviews>
@@ -216,7 +216,7 @@
216216
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
217217
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
218218
<subviews>
219-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
219+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
220220
<rect key="frame" x="8" y="144" width="359" height="33"/>
221221
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
222222
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -260,7 +260,7 @@
260260
<constraint firstItem="Y42-Ey-vw7" firstAttribute="leading" secondItem="MlD-Ep-TLw" secondAttribute="leading" constant="8" id="BwL-bC-XtC"/>
261261
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="Y42-Ey-vw7" secondAttribute="trailing" constant="8" id="KO9-tt-sh4"/>
262262
<constraint firstItem="Y42-Ey-vw7" firstAttribute="top" secondItem="MlD-Ep-TLw" secondAttribute="top" constant="8" id="Wgh-YA-x0t"/>
263-
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" constant="8" id="ftY-9Y-9jj"/>
263+
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" priority="999" constant="8" id="ftY-9Y-9jj"/>
264264
<constraint firstItem="bD7-AD-2Jb" firstAttribute="top" secondItem="Y42-Ey-vw7" secondAttribute="bottom" constant="8" id="lJV-gI-mej"/>
265265
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="bD7-AD-2Jb" secondAttribute="trailing" constant="8" id="xx1-Ba-dxI"/>
266266
</constraints>

Example/GrowingTextView/Example1.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class Example1: UIViewController {
3838
inputToolbar.addSubview(textView)
3939

4040
// *** Autolayout ***
41+
let topConstraint = textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
42+
topConstraint.priority = UILayoutPriority(999)
4143
NSLayoutConstraint.activate([
4244
inputToolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
4345
inputToolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
4446
inputToolbar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
45-
textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
47+
topConstraint
4648
])
4749

4850
if #available(iOS 11, *) {
@@ -62,7 +64,7 @@ class Example1: UIViewController {
6264
}
6365

6466
// *** Listen to keyboard show / hide ***
65-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
67+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
6668

6769
// *** Hide keyboard when tapping outside ***
6870
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapGestureHandler))
@@ -74,7 +76,7 @@ class Example1: UIViewController {
7476
}
7577

7678
@objc private func keyboardWillChangeFrame(_ notification: Notification) {
77-
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
79+
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
7880
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
7981
if #available(iOS 11, *) {
8082
if keyboardHeight > 0 {

Example/GrowingTextView/Example2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Example2: UIViewController {
2222
textView.layer.cornerRadius = 4.0
2323

2424
// *** Listen to keyboard show / hide ***
25-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
25+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
2626

2727
// *** Hide keyboard when tapping outside ***
2828
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapGestureHandler))
@@ -34,7 +34,7 @@ class Example2: UIViewController {
3434
}
3535

3636
@objc private func keyboardWillChangeFrame(_ notification: Notification) {
37-
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
37+
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
3838
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
3939
if #available(iOS 11, *) {
4040
if keyboardHeight > 0 {

GrowingTextView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "GrowingTextView"
11-
s.version = "0.5.6"
11+
s.version = "0.6.0"
1212
s.summary = "UITextView on Swift 3 and Swift 4. Support auto growing, placeholder and length limit."
1313

1414
# This description is used to generate tags and improve search results.

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ iOS 8.0 or above
1919
GrowingTextView is available through [CocoaPods](http://cocoapods.org). To install
2020
it, simply add the following line to your Podfile:
2121

22-
Swift 4<br>
22+
Swift 4.2<br>
23+
24+
```ruby
25+
pod 'GrowingTextView', '~> 0.6'
26+
```
27+
28+
Swift 4.1<br>
2329

2430
```ruby
2531
pod 'GrowingTextView', '~> 0.5'
@@ -41,7 +47,13 @@ GrowingTextView is also available through
4147
[Carthage](https://github.com/Carthage/Carthage). To install it, add the following
4248
line to your Cartfile:
4349

44-
Swift 4<br>
50+
Swift 4.2<br>
51+
52+
```ruby
53+
github "KennethTsang/GrowingTextView" ~> 0.6
54+
```
55+
56+
Swift 4.1<br>
4557

4658
```ruby
4759
github "KennethTsang/GrowingTextView" ~> 0.5

0 commit comments

Comments
 (0)