新增房间类型变化通知的发送和监听功能,优化 RoomAnimationView 的手势处理逻辑,提升用户体验。同时,增加触摸事件日志记录,便于调试和分析。

This commit is contained in:
edwinQQQ
2025-08-22 14:19:15 +08:00
parent cd9c2ea15a
commit 48053bc2c9
3 changed files with 113 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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