Skip to content

Commit 012ef1d

Browse files
committed
- Added couple of compile time validations for Xcode 11, iOS 13
- DisplayMode Default is renamed to default, I think this will not be a big deal to rename. - Removed support for Xcode 8 - Swift Code Style improvements using swiftlint
1 parent 6bb705e commit 012ef1d

27 files changed

+549
-548
lines changed

.gitignore

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Xcode
2-
#
32
build/
43
*.pbxuser
54
!default.pbxuser
@@ -16,11 +15,25 @@ DerivedData
1615
*.hmap
1716
*.ipa
1817
*.xcuserstate
18+
19+
#CocoaPods
1920
Pods/
2021

2122
# MacOS X
22-
#
2323
.DS_Store
2424
*.DS_Store
2525
**/.DS_Store
2626

27+
#Swift Package Manager
28+
.build
29+
/.previous-build
30+
*~
31+
\#*
32+
.\#*
33+
*.xcscmblueprint
34+
/default.profraw
35+
Utilities/Docker/*.tar.gz
36+
.swiftpm
37+
Packages/
38+
Package.pins
39+
Package.resolved

Demo/Objective_C_Demo/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>6.3</string>
20+
<string>6.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>6.3.0</string>
24+
<string>6.4.0</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
2727
<key>UILaunchStoryboardName</key>

Demo/Swift_Demo/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>6.3</string>
20+
<string>6.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>6.3.0</string>
24+
<string>6.4.0</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
2727
<key>UILaunchStoryboardName</key>

IQKeyboardManager.podspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "IQKeyboardManager",
3-
"version": "6.3.0",
3+
"version": "6.4.0",
44
"source": {
55
"git": "https://github.com/hackiftekhar/IQKeyboardManager.git",
6-
"tag": "v6.3.0"
6+
"tag": "v6.4.0"
77
},
88
"summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.",
99
"homepage": "https://github.com/hackiftekhar/IQKeyboardManager",

IQKeyboardManager/Constants/IQKeyboardManagerConstantsInternal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,4 @@
2525
#define IQKeyboardManagerConstantsInternal_h
2626

2727

28-
#define IQ_IS_IOS10_OR_GREATER ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 10)
29-
#define IQ_IS_IOS9_OR_GREATER ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 9)
30-
3128
#endif

IQKeyboardManager/IQKeyboardManager.m

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#import <UIKit/UIWindow.h>
5252
#import <UIKit/NSLayoutConstraint.h>
5353
#import <UIKit/UIStackView.h>
54+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
55+
#import <UIKit/UIWindowScene.h>
56+
#import <UIKit/UIStatusBarManager.h>
57+
#endif
5458

5559
NSInteger const kIQDoneButtonToolbarTag = -1002;
5660
NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
@@ -650,8 +654,21 @@ -(void)adjustPosition
650654
kbSize = intersectRect.size;
651655
}
652656
}
653-
654-
CGFloat navigationBarAreaHeight = [[UIApplication sharedApplication] statusBarFrame].size.height + rootController.navigationController.navigationBar.frame.size.height;
657+
658+
CGFloat statusBarHeight = 0;
659+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
660+
if (@available(iOS 13.0, *)) {
661+
statusBarHeight = [self keyWindow].windowScene.statusBarManager.statusBarFrame.size.height;
662+
663+
} else
664+
#endif
665+
{
666+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
667+
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
668+
#endif
669+
}
670+
671+
CGFloat navigationBarAreaHeight = statusBarHeight + rootController.navigationController.navigationBar.frame.size.height;
655672
CGFloat layoutAreaHeight = rootController.view.layoutMargins.top;
656673

657674
CGFloat topLayoutGuide = MAX(navigationBarAreaHeight, layoutAreaHeight) + 5;
@@ -710,11 +727,8 @@ -(void)adjustPosition
710727
[self showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(_startingContentOffset)]];
711728

712729
BOOL animatedContentOffset = NO; // (Bug ID: #1365, #1508, #1541)
713-
#ifdef __IPHONE_11_0
730+
714731
if (@available(iOS 9.0, *))
715-
#else
716-
if (IQ_IS_IOS9_OR_GREATER)
717-
#endif
718732
{
719733
animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
720734
}
@@ -755,11 +769,8 @@ -(void)adjustPosition
755769
[self showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(_startingContentOffset)]];
756770

757771
BOOL animatedContentOffset = NO; // (Bug ID: #1365, #1508, #1541)
758-
#ifdef __IPHONE_11_0
772+
759773
if (@available(iOS 9.0, *))
760-
#else
761-
if (IQ_IS_IOS9_OR_GREATER)
762-
#endif
763774
{
764775
animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
765776
}
@@ -774,8 +785,17 @@ -(void)adjustPosition
774785
_lastScrollView = superScrollView;
775786
strongLastScrollView = _lastScrollView;
776787
_startingContentInsets = superScrollView.contentInset;
777-
_startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
778788
_startingContentOffset = superScrollView.contentOffset;
789+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
790+
if (@available(iOS 11.1, *)) {
791+
_startingScrollIndicatorInsets = superScrollView.verticalScrollIndicatorInsets;
792+
} else
793+
#endif
794+
{
795+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
796+
_startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
797+
#endif
798+
}
779799

780800
[self showLog:[NSString stringWithFormat:@"Saving New contentInset: %@ and contentOffset : %@",NSStringFromUIEdgeInsets(_startingContentInsets),NSStringFromCGPoint(_startingContentOffset)]];
781801
}
@@ -788,7 +808,16 @@ -(void)adjustPosition
788808
strongLastScrollView = _lastScrollView;
789809
_startingContentInsets = superScrollView.contentInset;
790810
_startingContentOffset = superScrollView.contentOffset;
791-
_startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
811+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
812+
if (@available(iOS 11.1, *)) {
813+
_startingScrollIndicatorInsets = superScrollView.verticalScrollIndicatorInsets;
814+
} else
815+
#endif
816+
{
817+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
818+
_startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
819+
#endif
820+
}
792821

793822
[self showLog:[NSString stringWithFormat:@"Saving contentInset: %@ and contentOffset : %@",NSStringFromUIEdgeInsets(_startingContentInsets),NSStringFromCGPoint(_startingContentOffset)]];
794823
}
@@ -946,11 +975,8 @@ -(void)adjustPosition
946975
[strongSelf showLog:[NSString stringWithFormat:@"Remaining Move: %.2f",move]];
947976

948977
BOOL animatedContentOffset = NO; // (Bug ID: #1365, #1508, #1541)
949-
#ifdef __IPHONE_11_0
978+
950979
if (@available(iOS 9.0, *))
951-
#else
952-
if (IQ_IS_IOS9_OR_GREATER)
953-
#endif
954980
{
955981
animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:superScrollView] != nil);
956982
}
@@ -995,8 +1021,18 @@ -(void)adjustPosition
9951021
[UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
9961022

9971023
strongLastScrollView.contentInset = movedInsets;
998-
999-
UIEdgeInsets newInset = strongLastScrollView.scrollIndicatorInsets;
1024+
UIEdgeInsets newInset;
1025+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1026+
if (@available(iOS 11.1, *)) {
1027+
newInset = strongLastScrollView.verticalScrollIndicatorInsets;
1028+
} else
1029+
#endif
1030+
{
1031+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
1032+
newInset = strongLastScrollView.scrollIndicatorInsets;
1033+
#endif
1034+
}
1035+
10001036
newInset.bottom = movedInsets.bottom;
10011037
strongLastScrollView.scrollIndicatorInsets = newInset;
10021038

@@ -1029,7 +1065,17 @@ -(void)adjustPosition
10291065
if (self.isTextViewContentInsetChanged == NO)
10301066
{
10311067
self.startingTextViewContentInsets = textView.contentInset;
1032-
self.startingTextViewScrollIndicatorInsets = textView.scrollIndicatorInsets;
1068+
1069+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1070+
if (@available(iOS 11.1, *)) {
1071+
self.startingTextViewScrollIndicatorInsets = textView.verticalScrollIndicatorInsets;
1072+
} else
1073+
#endif
1074+
{
1075+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
1076+
self.startingTextViewScrollIndicatorInsets = textView.scrollIndicatorInsets;
1077+
#endif
1078+
}
10331079
}
10341080

10351081
UIEdgeInsets newContentInset = textView.contentInset;
@@ -1345,11 +1391,8 @@ - (void)keyboardWillHide:(NSNotification*)aNotification
13451391
[strongSelf showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(strongSelf.startingContentOffset)]];
13461392

13471393
BOOL animatedContentOffset = NO; // (Bug ID: #1365, #1508, #1541)
1348-
#ifdef __IPHONE_11_0
1394+
13491395
if (@available(iOS 9.0, *))
1350-
#else
1351-
if (IQ_IS_IOS9_OR_GREATER)
1352-
#endif
13531396
{
13541397
animatedContentOffset = ([strongTextFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
13551398
}
@@ -1378,11 +1421,8 @@ - (void)keyboardWillHide:(NSNotification*)aNotification
13781421
[self showLog:[NSString stringWithFormat:@"Restoring contentOffset to : %@",NSStringFromCGPoint(newContentOffset)]];
13791422

13801423
BOOL animatedContentOffset = NO; // (Bug ID: #1365, #1508, #1541)
1381-
#ifdef __IPHONE_11_0
1424+
13821425
if (@available(iOS 9.0, *))
1383-
#else
1384-
if (IQ_IS_IOS9_OR_GREATER)
1385-
#endif
13861426
{
13871427
animatedContentOffset = ([strongSelf.textFieldView superviewOfClassType:[UIStackView class] belowView:superscrollView] != nil);
13881428
}
@@ -1590,6 +1630,28 @@ -(void)textFieldViewDidEndEditing:(NSNotification*)notification
15901630
/** UIApplicationWillChangeStatusBarOrientationNotification. Need to set the textView to it's original position. If any frame changes made. (Bug ID: #92)*/
15911631
- (void)willChangeStatusBarOrientation:(NSNotification*)aNotification
15921632
{
1633+
UIInterfaceOrientation currentStatusBarOrientation = UIInterfaceOrientationUnknown;
1634+
1635+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1636+
if (@available(iOS 13.0, *)) {
1637+
currentStatusBarOrientation = [self keyWindow].windowScene.interfaceOrientation;
1638+
} else
1639+
#endif
1640+
{
1641+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
1642+
currentStatusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
1643+
#endif
1644+
}
1645+
1646+
#pragma clang diagnostic push
1647+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1648+
UIInterfaceOrientation statusBarOrientation = [aNotification.userInfo[UIApplicationStatusBarOrientationUserInfoKey] integerValue];
1649+
#pragma clang diagnostic pop
1650+
1651+
if (statusBarOrientation != currentStatusBarOrientation) {
1652+
return;
1653+
}
1654+
15931655
CFTimeInterval startTime = CACurrentMediaTime();
15941656
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)] indentation:1];
15951657

@@ -2260,7 +2322,10 @@ -(void)registerAllNotifications
22602322
didEndEditingNotificationName:UITextViewTextDidEndEditingNotification];
22612323

22622324
// Registering for orientation changes notification
2325+
#pragma clang diagnostic push
2326+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
22632327
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willChangeStatusBarOrientation:) name:UIApplicationWillChangeStatusBarOrientationNotification object:[UIApplication sharedApplication]];
2328+
#pragma clang diagnostic pop
22642329
}
22652330

22662331
-(void)unregisterAllNotifications
@@ -2282,7 +2347,10 @@ -(void)unregisterAllNotifications
22822347
didEndEditingNotificationName:UITextViewTextDidEndEditingNotification];
22832348

22842349
// Unregistering for orientation changes notification
2350+
#pragma clang diagnostic push
2351+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
22852352
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:[UIApplication sharedApplication]];
2353+
#pragma clang diagnostic pop
22862354
}
22872355

22882356
-(void)showLog:(NSString*)logString

IQKeyboardManager/IQKeyboardReturnKeyHandler.m

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,10 @@ - (void)textFieldDidEndEditing:(UITextField *)textField reason:(UITextFieldDidEn
345345
delegate = modal.textFieldDelegate;
346346
}
347347

348-
#ifdef __IPHONE_11_0
349348
if (@available(iOS 10.0, *)) {
350-
#endif
351349
if ([delegate respondsToSelector:@selector(textFieldDidEndEditing:reason:)])
352350
[delegate textFieldDidEndEditing:textField reason:reason];
353-
#ifdef __IPHONE_11_0
354351
}
355-
#endif
356352
}
357353

358354
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
@@ -539,14 +535,10 @@ - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRan
539535
delegate = modal.textViewDelegate;
540536
}
541537

542-
#ifdef __IPHONE_11_0
543538
if (@available(iOS 10.0, *)) {
544-
#endif
545539
if ([delegate respondsToSelector:@selector(textView:shouldInteractWithURL:inRange:interaction:)])
546540
return [delegate textView:textView shouldInteractWithURL:URL inRange:characterRange interaction:interaction];
547-
#ifdef __IPHONE_11_0
548541
}
549-
#endif
550542

551543
return YES;
552544
}
@@ -561,18 +553,15 @@ - (BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSText
561553
delegate = modal.textViewDelegate;
562554
}
563555

564-
#ifdef __IPHONE_11_0
565556
if (@available(iOS 10.0, *)) {
566-
#endif
567557
if ([delegate respondsToSelector:@selector(textView:shouldInteractWithTextAttachment:inRange:interaction:)])
568558
return [delegate textView:textView shouldInteractWithTextAttachment:textAttachment inRange:characterRange interaction:interaction];
569-
#ifdef __IPHONE_11_0
570559
}
571-
#endif
572560

573561
return YES;
574562
}
575563

564+
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
576565
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
577566
{
578567
id<UITextViewDelegate> delegate = self.delegate;
@@ -583,11 +572,8 @@ - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRan
583572
delegate = modal.textViewDelegate;
584573
}
585574

586-
#pragma clang diagnostic push
587-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
588575
if ([delegate respondsToSelector:@selector(textView:shouldInteractWithURL:inRange:)])
589576
return [delegate textView:textView shouldInteractWithURL:URL inRange:characterRange];
590-
#pragma clang diagnostic pop
591577
else
592578
return YES;
593579
}
@@ -602,14 +588,12 @@ - (BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSText
602588
delegate = modal.textViewDelegate;
603589
}
604590

605-
#pragma clang diagnostic push
606-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
607591
if ([delegate respondsToSelector:@selector(textView:shouldInteractWithTextAttachment:inRange:)])
608592
return [delegate textView:textView shouldInteractWithTextAttachment:textAttachment inRange:characterRange];
609-
#pragma clang diagnostic pop
610593
else
611594
return YES;
612595
}
596+
#endif
613597

614598
-(void)dealloc
615599
{

0 commit comments

Comments
 (0)