在 RoomAnimationView 中新增触摸事件处理逻辑,确保在没有 banner 显示或 banner 容器不可见时不接收触摸事件,提升用户交互体验。同时,优化了 banner 区域的触摸点检测逻辑,增强代码可读性。
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
// Created by P on 2025/1/13.
|
// Created by P on 2025/1/13.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//banner 手势处理会有遮挡其他视图操作的问题
|
||||||
|
|
||||||
#import "RoomAnimationView.h"
|
#import "RoomAnimationView.h"
|
||||||
|
|
||||||
#import <POP.h>
|
#import <POP.h>
|
||||||
@@ -201,6 +203,9 @@ XPRoomGraffitiGiftAnimationViewDelegate
|
|||||||
self.hostDelegate = hDelegate;
|
self.hostDelegate = hDelegate;
|
||||||
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
|
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
|
||||||
|
|
||||||
|
// 确保RoomAnimationView可以接收用户交互
|
||||||
|
self.userInteractionEnabled = YES;
|
||||||
|
|
||||||
[self setup];
|
[self setup];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@@ -1165,7 +1170,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
|
|||||||
NSLog(@"🧪 原始banner类型: %@", NSStringFromClass([obj class]));
|
NSLog(@"🧪 原始banner类型: %@", NSStringFromClass([obj class]));
|
||||||
|
|
||||||
// 添加原始数据
|
// 添加原始数据
|
||||||
[self.roomBannertModelsQueueV2 addObject:obj];
|
[self.roomBannertModelsQueueV2 addObject:obj];
|
||||||
|
|
||||||
// 复制指定份数
|
// 复制指定份数
|
||||||
for (int i = 1; i < copyCount; i++) {
|
for (int i = 1; i < copyCount; i++) {
|
||||||
@@ -4027,4 +4032,34 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Touch Event Handling
|
||||||
|
|
||||||
|
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
|
||||||
|
// 检查是否有banner显示
|
||||||
|
if (self.bannerContainer.subviews.count == 0) {
|
||||||
|
NSLog(@"🎯 没有banner显示,不接收触摸事件");
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查banner容器是否可见
|
||||||
|
if (self.bannerContainer.hidden || self.bannerContainer.alpha <= 0.01) {
|
||||||
|
NSLog(@"🎯 banner容器不可见,不接收触摸事件");
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查触摸点是否在bannerContainer区域内
|
||||||
|
CGPoint bannerPoint = [self.bannerContainer convertPoint:point fromView:self];
|
||||||
|
if (CGRectContainsPoint(self.bannerContainer.bounds, bannerPoint)) {
|
||||||
|
NSLog(@"🎯 触摸在banner区域内,接收触摸事件");
|
||||||
|
return [super pointInside:point withEvent:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在banner区域外,不接收触摸事件,让下层视图处理
|
||||||
|
NSLog(@"🎯 触摸在banner区域外,穿透到下层视图 - 触摸点:(%.1f,%.1f) banner区域:(%.1f,%.1f,%.1f,%.1f)",
|
||||||
|
point.x, point.y,
|
||||||
|
self.bannerContainer.frame.origin.x, self.bannerContainer.frame.origin.y,
|
||||||
|
self.bannerContainer.frame.size.width, self.bannerContainer.frame.size.height);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user