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
5559NSInteger const kIQDoneButtonToolbarTag = -1002 ;
5660NSInteger 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
0 commit comments