diff --git a/Pod/Source/TRTouchposeApplication.m b/Pod/Source/TRTouchposeApplication.m index 3115f31..cea2275 100644 --- a/Pod/Source/TRTouchposeApplication.m +++ b/Pod/Source/TRTouchposeApplication.m @@ -74,20 +74,33 @@ - (instancetype)initWithFrame:(CGRect)frame touchViewFactory:(id 0) { - void const * keys[count]; - void const * values[count]; - CFDictionaryGetKeysAndValues(_touchDictionary, keys, values); + void const *keys[count]; + void const *values[count]; + bool active[count]; // active[i] will be set to true if key[i] exists in activeTouches + for (CFIndex i = 0; i < count; ++i) + active[i] = false; + + CFDictionaryGetKeysAndValues(_touchDictionary, keys, values); + + for (UITouch *touch in activeTouches) { - UITouch *touch = (__bridge UITouch *)keys[i]; + for (CFIndex i = 0; i < count; ++i) + { + if (keys[i] == (__bridge const void *)touch) + active[i] = true; + } + } - if (activeTouches == nil || ![activeTouches containsObject:touch]) + for (CFIndex i = 0; i < count; ++i) + { + if (!active[i]) { UIView *view = (__bridge UIView *)values[i]; - CFDictionaryRemoveValue(_touchDictionary, (__bridge const void *)(touch)); + CFDictionaryRemoveValue(_touchDictionary, keys[i]); [view removeFromSuperview]; } }