新增房间类型变化通知的发送和监听功能,优化 RoomAnimationView 的手势处理逻辑,提升用户体验。同时,增加触摸事件日志记录,便于调试和分析。
This commit is contained in:
@@ -176,6 +176,9 @@ BannerSchedulerDelegate
|
||||
// Banner 手势相关属性
|
||||
@property(nonatomic, assign) CGPoint savedTapPoint;
|
||||
@property(nonatomic, assign) BOOL hasSavedTapPoint;
|
||||
|
||||
@property (nonatomic, strong) UISwipeGestureRecognizer *swipeWhenPlayGame;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RoomAnimationView
|
||||
@@ -360,6 +363,12 @@ BannerSchedulerDelegate
|
||||
[self setupOldMethods];
|
||||
|
||||
[self addBnnerContainGesture];
|
||||
|
||||
// 🔧 新增:监听房间类型变化
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleRoomTypeChanged:)
|
||||
name:@"RoomTypeChanged"
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
@@ -2306,6 +2315,27 @@ BannerSchedulerDelegate
|
||||
}
|
||||
|
||||
#pragma mark - Gesture
|
||||
- (void)addBannerContainGestureWhenPlayGame {
|
||||
_swipeWhenPlayGame = [[UISwipeGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(handleSwipe)];
|
||||
if (isMSRTL()) {
|
||||
_swipeWhenPlayGame.direction = UISwipeGestureRecognizerDirectionRight;
|
||||
} else {
|
||||
_swipeWhenPlayGame.direction = UISwipeGestureRecognizerDirectionLeft;
|
||||
}
|
||||
|
||||
[self.bannerContainer addGestureRecognizer:_swipeWhenPlayGame];
|
||||
}
|
||||
|
||||
- (void)removeBannerContainGestureWhenPlayGame {
|
||||
[self.bannerContainer removeGestureRecognizer:self.swipeWhenPlayGame];
|
||||
_swipeWhenPlayGame = nil;
|
||||
}
|
||||
|
||||
- (void)handleSwipeWhenPlayGame {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"SwipeOutBanner" object:nil];
|
||||
}
|
||||
|
||||
- (void)addBnnerContainGesture {
|
||||
[self insertSubview:self.bannerSwipeGestureContainer aboveSubview:self.bannerContainer];
|
||||
[self insertSubview:self.bannerLeftTapGestureContainer aboveSubview:self.bannerContainer];
|
||||
@@ -3727,6 +3757,9 @@ BannerSchedulerDelegate
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"TapBanner" object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"BannerTapToFunctionContainer" object:nil];
|
||||
|
||||
// 🔧 新增:移除房间类型变化通知监听
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"RoomTypeChanged" object:nil];
|
||||
|
||||
// 移除其他可能添加的通知监听
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
@@ -3823,4 +3856,54 @@ BannerSchedulerDelegate
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 房间类型手势容器控制
|
||||
|
||||
// 处理房间类型变化
|
||||
- (void)handleRoomTypeChanged:(NSNotification *)notification {
|
||||
NSDictionary *userInfo = notification.userInfo;
|
||||
NSInteger roomType = [userInfo[@"roomType"] integerValue];
|
||||
|
||||
if (roomType == RoomType_MiniGame) {
|
||||
NSLog(@"🎯 RoomAnimationView: 检测到小游戏房间,设置 banner 手势穿透模式");
|
||||
[self setBannerGesturePassthroughMode];
|
||||
[self addBannerContainGestureWhenPlayGame];
|
||||
} else {
|
||||
NSLog(@"🎯 RoomAnimationView: 检测到非小游戏房间,恢复 banner 手势正常模式");
|
||||
[self restoreBannerGestureNormalMode];
|
||||
[self removeBannerContainGestureWhenPlayGame];
|
||||
}
|
||||
}
|
||||
|
||||
// 设置 banner 手势为穿透模式(用于 LittleGameScrollStageView)
|
||||
- (void)setBannerGesturePassthroughMode {
|
||||
// 隐藏手势容器
|
||||
self.bannerSwipeGestureContainer.hidden = YES;
|
||||
self.bannerLeftTapGestureContainer.hidden = YES;
|
||||
self.bannerRightTapGestureContainer.hidden = YES;
|
||||
|
||||
// 禁用用户交互
|
||||
self.bannerSwipeGestureContainer.userInteractionEnabled = NO;
|
||||
self.bannerLeftTapGestureContainer.userInteractionEnabled = NO;
|
||||
self.bannerRightTapGestureContainer.userInteractionEnabled = NO;
|
||||
|
||||
NSLog(@"🎯 RoomAnimationView: Banner 手势容器已隐藏(小游戏模式)");
|
||||
}
|
||||
|
||||
// 恢复 banner 手势正常模式
|
||||
- (void)restoreBannerGestureNormalMode {
|
||||
// 显示手势容器
|
||||
self.bannerSwipeGestureContainer.hidden = NO;
|
||||
self.bannerLeftTapGestureContainer.hidden = NO;
|
||||
self.bannerRightTapGestureContainer.hidden = NO;
|
||||
|
||||
// 启用用户交互
|
||||
self.bannerSwipeGestureContainer.userInteractionEnabled = YES;
|
||||
self.bannerLeftTapGestureContainer.userInteractionEnabled = YES;
|
||||
self.bannerRightTapGestureContainer.userInteractionEnabled = YES;
|
||||
|
||||
NSLog(@"🎯 RoomAnimationView: Banner 手势容器已恢复显示(非小游戏模式)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -161,5 +161,30 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
#pragma mark - 触摸事件日志
|
||||
|
||||
// 触摸开始
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"🎯 LittleGameScrollStageView: touchesBegan 被调用");
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
}
|
||||
|
||||
// 触摸移动
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"🎯 LittleGameScrollStageView: touchesMoved 被调用");
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
}
|
||||
|
||||
// 触摸结束
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"🎯 LittleGameScrollStageView: touchesEnded 被调用");
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
}
|
||||
|
||||
// 触摸取消
|
||||
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"🎯 LittleGameScrollStageView: touchesCancelled 被调用");
|
||||
[super touchesCancelled:touches withEvent:event];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -932,6 +932,11 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
if (![self updateStageView]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔧 新增:发送房间类型变化通知
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"RoomTypeChanged"
|
||||
object:nil
|
||||
userInfo:@{@"roomType": @(self.roomInfo.type)}];
|
||||
|
||||
if (!self.stageView.superview) {
|
||||
[self.view insertSubview:self.stageView
|
||||
|
Reference in New Issue
Block a user