Skip to content

Commit 376afa9

Browse files
committed
#29 Fixed keyboard position calculation in case using opaque navigation bar.
1 parent 21a4220 commit 376afa9

File tree

10 files changed

+31
-22
lines changed

10 files changed

+31
-22
lines changed

Example/GrowingTextView.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
isa = PBXProject;
220220
attributes = {
221221
LastSwiftUpdateCheck = 0720;
222-
LastUpgradeCheck = 0900;
222+
LastUpgradeCheck = 0930;
223223
ORGANIZATIONNAME = CocoaPods;
224224
TargetAttributes = {
225225
607FACCF1AFB9204008FA782 = {
@@ -429,12 +429,14 @@
429429
CLANG_WARN_BOOL_CONVERSION = YES;
430430
CLANG_WARN_COMMA = YES;
431431
CLANG_WARN_CONSTANT_CONVERSION = YES;
432+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
432433
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
433434
CLANG_WARN_EMPTY_BODY = YES;
434435
CLANG_WARN_ENUM_CONVERSION = YES;
435436
CLANG_WARN_INFINITE_RECURSION = YES;
436437
CLANG_WARN_INT_CONVERSION = YES;
437438
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
439+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
438440
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
439441
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
440442
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -482,12 +484,14 @@
482484
CLANG_WARN_BOOL_CONVERSION = YES;
483485
CLANG_WARN_COMMA = YES;
484486
CLANG_WARN_CONSTANT_CONVERSION = YES;
487+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
485488
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
486489
CLANG_WARN_EMPTY_BODY = YES;
487490
CLANG_WARN_ENUM_CONVERSION = YES;
488491
CLANG_WARN_INFINITE_RECURSION = YES;
489492
CLANG_WARN_INT_CONVERSION = YES;
490493
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
494+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
491495
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
492496
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
493497
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;

Example/GrowingTextView.xcodeproj/xcshareddata/xcschemes/GrowingTextView-Example.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -40,7 +40,6 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43-
language = ""
4443
shouldUseLaunchSchemeArgsEnv = "YES">
4544
<Testables>
4645
<TestableReference
@@ -70,7 +69,6 @@
7069
buildConfiguration = "Debug"
7170
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7271
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73-
language = ""
7472
launchStyle = "0"
7573
useCustomWorkingDirectory = "NO"
7674
ignoresPersistentStateOnLaunch = "NO"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Example/GrowingTextView/Base.lproj/Main.storyboard

Lines changed: 4 additions & 4 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="13771" 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="14109" 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="13772"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
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" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
127+
<view contentMode="scaleToFill" ambiguous="YES" 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" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
130+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" 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"/>

Example/GrowingTextView/Example1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Example1: UIViewController {
7575

7676
@objc private func keyboardWillChangeFrame(_ notification: Notification) {
7777
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
78-
var keyboardHeight = view.bounds.height - endFrame.origin.y
78+
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
7979
if #available(iOS 11, *) {
8080
if keyboardHeight > 0 {
8181
keyboardHeight = keyboardHeight - view.safeAreaInsets.bottom

Example/GrowingTextView/Example2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Example2: UIViewController {
3535

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

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/GrowingTextView.xcscheme

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.5"
11+
s.version = "0.5.6"
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.

Pod/Classes/GrowingTextView.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ open class GrowingTextView: UITextView {
168168

169169
// Trim white space and new line characters when end editing.
170170
@objc func textDidEndEditing(notification: Notification) {
171-
if let notificationObject = notification.object as? GrowingTextView {
172-
if notificationObject === self {
173-
if trimWhiteSpaceWhenEndEditing {
174-
text = text?.trimmingCharacters(in: .whitespacesAndNewlines)
175-
setNeedsDisplay()
176-
}
171+
if let sender = notification.object as? GrowingTextView, sender == self {
172+
if trimWhiteSpaceWhenEndEditing {
173+
text = text?.trimmingCharacters(in: .whitespacesAndNewlines)
174+
setNeedsDisplay()
177175
}
178176
scrollToCorrectPosition()
179177
}
@@ -191,4 +189,3 @@ open class GrowingTextView: UITextView {
191189
}
192190
}
193191
}
194-

0 commit comments

Comments
 (0)