summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-04-02 11:28:23 -0400
committerNicoleYarroch <nicole@livio.io>2019-04-02 11:28:23 -0400
commit95e7547b92b78e8e806c674369f26558cede59d1 (patch)
treedb976d5a8b3bdbc1aea367a94c9ff36a4118f8fc
parent04fd7bbf73ed09019c03f19d2ea5bfdb08810e17 (diff)
downloadsdl_ios-95e7547b92b78e8e806c674369f26558cede59d1.tar.gz
Single tap hit view is now done on main thread
checking if single tap hit a view is now done on main thread
-rw-r--r--SmartDeviceLink/SDLTouchManager.m20
1 files changed, 17 insertions, 3 deletions
diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m
index 4788ab03a..a6d220d1a 100644
--- a/SmartDeviceLink/SDLTouchManager.m
+++ b/SmartDeviceLink/SDLTouchManager.m
@@ -420,12 +420,27 @@ static NSUInteger const MaximumNumberOfTouches = 2;
strongSelf.singleTapTouch = nil;
[strongSelf sdl_cancelSingleTapTimer];
if ([strongSelf.touchEventDelegate respondsToSelector:@selector(touchManager:didReceiveSingleTapForView:atPoint:)]) {
- UIView *hitView = (self.hitTester != nil) ? [self.hitTester viewForPoint:point] : nil;
- [strongSelf.touchEventDelegate touchManager:strongSelf didReceiveSingleTapForView:hitView atPoint:point];
+ [self sdl_getSingleTapHitView:point hitViewHandler:^(UIView * _Nullable selectedView) {
+ [strongSelf.touchEventDelegate touchManager:strongSelf didReceiveSingleTapForView:selectedView atPoint:point];
+ }];
}
});
}
+- (void)sdl_getSingleTapHitView:(CGPoint)point hitViewHandler:(nullable void (^)(UIView * __nullable hitView))hitViewSelector {
+ if (!self.hitTester) {
+ return hitViewSelector(nil);
+ }
+
+ NSOperationQueue *currentQueue = NSOperationQueue.currentQueue;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ UIView *hitView = [self.hitTester viewForPoint:point];
+ dispatch_async(currentQueue.underlyingQueue, ^{
+ return hitViewSelector(hitView);
+ });
+ });
+}
+
/**
* Cancels a tap gesture timer
*/
@@ -440,4 +455,3 @@ static NSUInteger const MaximumNumberOfTouches = 2;
@end
NS_ASSUME_NONNULL_END
-