From 5285eac14fd5f5d37defdadd7309352b6fa9eb36 Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 02:20:47 -0800 Subject: [PATCH 1/6] Comments out any private API usage --- Source/SLKInputAccessoryView.m | 8 ++++++++ Source/SLKTextView.m | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/SLKInputAccessoryView.m b/Source/SLKInputAccessoryView.m index d158d3be..3f198f64 100644 --- a/Source/SLKInputAccessoryView.m +++ b/Source/SLKInputAccessoryView.m @@ -27,6 +27,13 @@ - (void)willMoveToSuperview:(UIView *)newSuperview if (newSuperview) { if (SLK_IS_IOS9_AND_HIGHER) { + // NOTE: Because the keyboard is on its own view hiearchy since iOS 9, + // we needed to lookup for its view so we can move the text input whenever its origin changed. + // We are disabling the detection of the keyboard on iOS 9 until a public API is available. + // + // Open Radar: http://openradar.appspot.com/radar?id=5021485877952512 + + /* NSPredicate *windowPredicate = [NSPredicate predicateWithFormat:@"self isMemberOfClass: %@", NSClassFromString(@"UIRemoteKeyboardWindow")]; UIWindow *keyboardWindow = [[[UIApplication sharedApplication].windows filteredArrayUsingPredicate:windowPredicate] firstObject]; @@ -38,6 +45,7 @@ - (void)willMoveToSuperview:(UIView *)newSuperview } } } + */ } else { _keyboardViewProxy = newSuperview; diff --git a/Source/SLKTextView.m b/Source/SLKTextView.m index 9b0bfde9..28afbb31 100644 --- a/Source/SLKTextView.m +++ b/Source/SLKTextView.m @@ -689,12 +689,19 @@ - (void)forwardInvocation:(NSInvocation *)invocation - (void)slk_gestureRecognized:(UIGestureRecognizer *)gesture { - // In iOS 8 and earlier, the gesture recognizer responsible for the magnifying glass movement was 'UIVariableDelayLoupeGesture' - // Since iOS 9, that gesture is now called '_UITextSelectionForceGesture' + // NOTE: + // In iOS 8 and earlier, the gesture recognizer responsible for the magnifying glass movement was 'UIVariableDelayLoupeGesture'. + // That gesture is called '_UITextSelectionForceGesture' since iOS 9. + // We are disabling the detection of these gesture objects until a public API is available. + // + // Open Radar: http://openradar.appspot.com/radar?id=5021485877952512 + + /* if ([gesture isMemberOfClass:NSClassFromString(@"UIVariableDelayLoupeGesture")] || [gesture isMemberOfClass:NSClassFromString(@"_UITextSelectionForceGesture")]) { [self slk_willShowLoupe:gesture]; } + */ } - (void)slk_willShowLoupe:(UIGestureRecognizer *)gesture From 3fffcf10b07f7a6e4c953505b9221d67bcd37eaf Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 11:19:52 -0800 Subject: [PATCH 2/6] Skip any panning gesture handling if the keyboard's view has been detected. --- Examples/Messenger.xcodeproj/project.pbxproj | 2 +- Source/SLKTextViewController.h | 5 ++++- Source/SLKTextViewController.m | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Examples/Messenger.xcodeproj/project.pbxproj b/Examples/Messenger.xcodeproj/project.pbxproj index e693ebf4..65393e38 100644 --- a/Examples/Messenger.xcodeproj/project.pbxproj +++ b/Examples/Messenger.xcodeproj/project.pbxproj @@ -426,7 +426,7 @@ ORGANIZATIONNAME = "Slack Technologies, Inc."; TargetAttributes = { 4F3EDB48199ED00F004C15D6 = { - DevelopmentTeam = BQR82RBBHL; + DevelopmentTeam = S6MX3RA9ZM; }; 4F86BF6419F011D0007A3D4A = { CreatedOnToolsVersion = 6.0.1; diff --git a/Source/SLKTextViewController.h b/Source/SLKTextViewController.h index da41fd66..70181841 100644 --- a/Source/SLKTextViewController.h +++ b/Source/SLKTextViewController.h @@ -85,7 +85,10 @@ NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController /** YES if text view's content can be cleaned with a shake gesture. Default is NO. */ @property (nonatomic, assign) BOOL shakeToClearEnabled; -/** YES if keyboard can be dismissed gradually with a vertical panning gesture. Default is YES. */ +/** + YES if keyboard can be dismissed gradually with a vertical panning gesture. Default is YES. + This feature is disabled on iOS 9 due to no legit alternatives to detect the keyboard frame. + */ @property (nonatomic, assign, getter = isKeyboardPanningEnabled) BOOL keyboardPanningEnabled; /** YES if an external keyboard has been detected (this value updates only when the text view becomes first responder). */ diff --git a/Source/SLKTextViewController.m b/Source/SLKTextViewController.m index 4427bb5c..512c076d 100644 --- a/Source/SLKTextViewController.m +++ b/Source/SLKTextViewController.m @@ -908,6 +908,11 @@ - (void)slk_handlePanGestureRecognizer:(UIPanGestureRecognizer *)gesture __block UIView *keyboardView = [self.textInputbar.inputAccessoryView keyboardViewProxy]; + // When no keyboard view has been detecting, let's skip any handling. + if (!keyboardView) { + return; + } + // Dynamic variables CGPoint gestureLocation = [gesture locationInView:self.view]; CGPoint gestureVelocity = [gesture velocityInView:self.view]; From 380b22b16d1031fa4873057ddb6f721028e7c46d Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 11:26:45 -0800 Subject: [PATCH 3/6] Tweaking the sample project's layout for better looking auto-completion cells --- Examples/Messenger-Shared/MessageTableViewCell.h | 3 +++ Examples/Messenger-Shared/MessageTableViewCell.m | 11 ++++++++--- Examples/Messenger-Shared/MessageViewController.m | 12 ++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Examples/Messenger-Shared/MessageTableViewCell.h b/Examples/Messenger-Shared/MessageTableViewCell.h index 919cadab..6baa73e2 100644 --- a/Examples/Messenger-Shared/MessageTableViewCell.h +++ b/Examples/Messenger-Shared/MessageTableViewCell.h @@ -11,6 +11,9 @@ static CGFloat kMessageTableViewCellMinimumHeight = 50.0; static CGFloat kMessageTableViewCellAvatarHeight = 30.0; +static NSString *MessengerCellIdentifier = @"MessengerCell"; +static NSString *AutoCompletionCellIdentifier = @"AutoCompletionCell"; + @interface MessageTableViewCell : UITableViewCell @property (nonatomic, strong) UILabel *titleLabel; diff --git a/Examples/Messenger-Shared/MessageTableViewCell.m b/Examples/Messenger-Shared/MessageTableViewCell.m index 432a72d6..f69927f3 100644 --- a/Examples/Messenger-Shared/MessageTableViewCell.m +++ b/Examples/Messenger-Shared/MessageTableViewCell.m @@ -37,14 +37,19 @@ - (void)configureSubviews NSDictionary *metrics = @{@"tumbSize": @(kMessageTableViewCellAvatarHeight), @"padding": @15, @"right": @10, - @"left": @5, - @"attchSize": @80, + @"left": @5 }; [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-left-[thumbnailView(tumbSize)]-right-[titleLabel(>=0)]-right-|" options:0 metrics:metrics views:views]]; [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-left-[thumbnailView(tumbSize)]-right-[bodyLabel(>=0)]-right-|" options:0 metrics:metrics views:views]]; - [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-right-[titleLabel(20)]-left-[bodyLabel(>=0@999)]-left-|" options:0 metrics:metrics views:views]]; [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-right-[thumbnailView(tumbSize)]-(>=0)-|" options:0 metrics:metrics views:views]]; + + if ([self.reuseIdentifier isEqualToString:MessengerCellIdentifier]) { + [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-right-[titleLabel(20)]-left-[bodyLabel(>=0@999)]-left-|" options:0 metrics:metrics views:views]]; + } + else { + [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[titleLabel]|" options:0 metrics:metrics views:views]]; + } } - (void)prepareForReuse diff --git a/Examples/Messenger-Shared/MessageViewController.m b/Examples/Messenger-Shared/MessageViewController.m index 28c77244..bd0c3c59 100644 --- a/Examples/Messenger-Shared/MessageViewController.m +++ b/Examples/Messenger-Shared/MessageViewController.m @@ -16,9 +16,6 @@ #define DEBUG_CUSTOM_TYPING_INDICATOR 0 -static NSString *MessengerCellIdentifier = @"MessengerCell"; -static NSString *AutoCompletionCellIdentifier = @"AutoCompletionCell"; - @interface MessageViewController () @property (nonatomic, strong) NSMutableArray *messages; @@ -570,17 +567,16 @@ - (MessageTableViewCell *)autoCompletionCellForRowAtIndexPath:(NSIndexPath *)ind MessageTableViewCell *cell = (MessageTableViewCell *)[self.autoCompletionView dequeueReusableCellWithIdentifier:AutoCompletionCellIdentifier]; cell.indexPath = indexPath; - NSString *item = self.searchResult[indexPath.row]; + NSString *text = self.searchResult[indexPath.row]; if ([self.foundPrefix isEqualToString:@"#"]) { - item = [NSString stringWithFormat:@"# %@", item]; + text = [NSString stringWithFormat:@"# %@", text]; } else if (([self.foundPrefix isEqualToString:@":"] || [self.foundPrefix isEqualToString:@"+:"])) { - item = [NSString stringWithFormat:@":%@:", item]; + text = [NSString stringWithFormat:@":%@:", text]; } - cell.titleLabel.text = item; - cell.titleLabel.font = [UIFont systemFontOfSize:14.0]; + cell.titleLabel.text = text; cell.selectionStyle = UITableViewCellSelectionStyleDefault; return cell; From 2e280aab976afd4ce83cee0f564ffd6756022840 Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 12:06:53 -0800 Subject: [PATCH 4/6] Deprecated 'isLoupeVisible' and added more documentation --- Source/SLKTextView.h | 6 ++++-- Source/SLKTextView.m | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/SLKTextView.h b/Source/SLKTextView.h index 22ecff3d..461d658f 100644 --- a/Source/SLKTextView.h +++ b/Source/SLKTextView.h @@ -68,8 +68,10 @@ typedef NS_OPTIONS(NSUInteger, SLKPastableMediaType) { /** YES if quickly refreshed the textview without the intension to dismiss the keyboard. @view -disableQuicktypeBar: for more details. */ @property (nonatomic, readwrite) BOOL didNotResignFirstResponder; -/** YES if the magnifying glass is visible. */ -@property (nonatomic, getter=isLoupeVisible) BOOL loupeVisible; +/** YES if the magnifying glass is visible. + This feature is deprecated since there are no legit alternatives to detect the magnifying glass. + */ +@property (nonatomic, getter=isLoupeVisible) BOOL loupeVisible DEPRECATED_ATTRIBUTE; /** YES if the keyboard track pad has been recognized. iOS 9 only. */ @property (nonatomic, readonly, getter=isTrackpadEnabled) BOOL trackpadEnabled; diff --git a/Source/SLKTextView.m b/Source/SLKTextView.m index 28afbb31..d17be87c 100644 --- a/Source/SLKTextView.m +++ b/Source/SLKTextView.m @@ -692,9 +692,14 @@ - (void)slk_gestureRecognized:(UIGestureRecognizer *)gesture // NOTE: // In iOS 8 and earlier, the gesture recognizer responsible for the magnifying glass movement was 'UIVariableDelayLoupeGesture'. // That gesture is called '_UITextSelectionForceGesture' since iOS 9. - // We are disabling the detection of these gesture objects until a public API is available. // + // We are disabling the detection of these gesture objects until a public API is available. // Open Radar: http://openradar.appspot.com/radar?id=5021485877952512 + // + // From now, the isLoupeVisible flag will always be false. + // Whenever a user hits a range that requires auto-completion, the magnifying glass would disappear. + // Why, you say? Because we need to reload the textView and disable auto-correction since it overrides any + // auto-completion while typing. /* if ([gesture isMemberOfClass:NSClassFromString(@"UIVariableDelayLoupeGesture")] || From b969ed3d571e6e92f9e172e1ea2840f9ce7db95b Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 12:10:06 -0800 Subject: [PATCH 5/6] Typo --- Source/SLKInputAccessoryView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SLKInputAccessoryView.m b/Source/SLKInputAccessoryView.m index 3f198f64..ca1ad094 100644 --- a/Source/SLKInputAccessoryView.m +++ b/Source/SLKInputAccessoryView.m @@ -27,7 +27,7 @@ - (void)willMoveToSuperview:(UIView *)newSuperview if (newSuperview) { if (SLK_IS_IOS9_AND_HIGHER) { - // NOTE: Because the keyboard is on its own view hiearchy since iOS 9, + // NOTE: Because the keyboard is on its own view hierarchy since iOS 9, // we needed to lookup for its view so we can move the text input whenever its origin changed. // We are disabling the detection of the keyboard on iOS 9 until a public API is available. // From c5aa1ec7391db9460da6502b917919fca4f88ab7 Mon Sep 17 00:00:00 2001 From: Ignacio Romero Zurbuchen Date: Wed, 6 Jan 2016 12:57:02 -0800 Subject: [PATCH 6/6] Tweaked documentation --- Source/SLKInputAccessoryView.m | 3 ++- Source/SLKTextView.m | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/SLKInputAccessoryView.m b/Source/SLKInputAccessoryView.m index ca1ad094..7c73f81e 100644 --- a/Source/SLKInputAccessoryView.m +++ b/Source/SLKInputAccessoryView.m @@ -27,7 +27,8 @@ - (void)willMoveToSuperview:(UIView *)newSuperview if (newSuperview) { if (SLK_IS_IOS9_AND_HIGHER) { - // NOTE: Because the keyboard is on its own view hierarchy since iOS 9, + // NOTE: + // Because the keyboard is on its own view hierarchy since iOS 9, // we needed to lookup for its view so we can move the text input whenever its origin changed. // We are disabling the detection of the keyboard on iOS 9 until a public API is available. // diff --git a/Source/SLKTextView.m b/Source/SLKTextView.m index d17be87c..c4070234 100644 --- a/Source/SLKTextView.m +++ b/Source/SLKTextView.m @@ -697,9 +697,9 @@ - (void)slk_gestureRecognized:(UIGestureRecognizer *)gesture // Open Radar: http://openradar.appspot.com/radar?id=5021485877952512 // // From now, the isLoupeVisible flag will always be false. - // Whenever a user hits a range that requires auto-completion, the magnifying glass would disappear. - // Why, you say? Because we need to reload the textView and disable auto-correction since it overrides any - // auto-completion while typing. + // Whenever a user activates the magnifying glass by long pressing on the text content area and moves the cursor into a range of text + // that requires auto-completion, the magnifying glass would disappear all of the sudden, causing erratic UI behaviours. + // Why, you say? Because we need to reload the textView and disable auto-correction since it overrides any auto-completion while typing. /* if ([gesture isMemberOfClass:NSClassFromString(@"UIVariableDelayLoupeGesture")] ||