From 3da0148ad183018d1ec991089e3f8ba36a6befa3 Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Wed, 13 Aug 2025 18:16:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=A4=9A=E4=B8=AA=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=20dismissBanner=20=E6=96=B9=E6=B3=95=E4=B8=AD?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E4=BE=BF=E4=BA=8E=E8=B0=83=E8=AF=95=E5=92=8C=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E5=8A=A8=E7=94=BB=E5=AE=8C=E6=88=90=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=9B=E5=9C=A8=20RoomAnimationView=20=E4=B8=AD=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20ensureDebugViewsExist=20=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E8=B0=83=E8=AF=95=E8=A7=86=E5=9B=BE=E7=9A=84?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=B9=B6=E4=BC=98=E5=8C=96=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E8=BE=93=E5=87=BA=EF=BC=9B=E5=9C=A8?= =?UTF-8?q?=20inserBannerModelToQueue=20=E6=96=B9=E6=B3=95=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0=E9=AA=8C=E8=AF=81=E5=92=8C?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84=E5=8F=AF=E8=AF=BB=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=83=BD=E5=8A=9B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AnimationView/GameUniversalBannerView.m | 4 + .../LuckyGiftWinningBannerView.m | 4 + .../View/AnimationView/RoomAnimationView.m | 154 +++++++++++++++++- .../RoomHighValueGiftBannerAnimation.m | 4 + 4 files changed, 165 insertions(+), 1 deletion(-) diff --git a/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m b/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m index dc9288c1..1e811135 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m @@ -77,12 +77,16 @@ } - (void)dismissBanner { + NSLog(@"🚨 GameUniversalBannerView dismissBanner 被调用"); self.alreadyCancel = YES; [self pop_removeAllAnimations]; // 停止所有动画 [self popLeaveAnimation:^(bool finished) { + NSLog(@"🚨 GameUniversalBannerView 动画完成,调用回调"); if (self.completeDisplay) { self.completeDisplay(); + } else { + NSLog(@"🚨 警告: completeDisplay 回调为空"); } [self removeFromSuperview]; }]; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/LuckyGiftWinningBannerView.m b/YuMi/Modules/YMRoom/View/AnimationView/LuckyGiftWinningBannerView.m index 21829c99..7e7389ac 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/LuckyGiftWinningBannerView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/LuckyGiftWinningBannerView.m @@ -133,11 +133,15 @@ exitCurrentRoom:(void(^)(void))exit { } - (void)dismissBanner { + NSLog(@"🚨 LuckyGiftWinningBannerView dismissBanner 被调用"); [self pop_removeAllAnimations]; // 停止所有动画 [self popLeaveAnimation:^(bool finished) { + NSLog(@"🚨 LuckyGiftWinningBannerView 动画完成,调用回调"); if (self.completeDisplay) { self.completeDisplay(); + } else { + NSLog(@"🚨 警告: completeDisplay 回调为空"); } [self removeFromSuperview]; }]; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m index e24ff9f1..67ce9ad1 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m @@ -421,6 +421,7 @@ XPRoomGraffitiGiftAnimationViewDelegate centerDebugView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3]; centerDebugView.frame = [self getCenterZone]; centerDebugView.userInteractionEnabled = NO; + centerDebugView.tag = 999; // 设置debug视图tag [self.bannerContainer addSubview:centerDebugView]; // 左侧区域 - 半透明红色 @@ -428,6 +429,7 @@ XPRoomGraffitiGiftAnimationViewDelegate leftDebugView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.3]; leftDebugView.frame = [self getLeftZone]; leftDebugView.userInteractionEnabled = NO; + leftDebugView.tag = 999; // 设置debug视图tag [self.bannerContainer addSubview:leftDebugView]; // 右侧区域 - 半透明绿色 @@ -435,6 +437,7 @@ XPRoomGraffitiGiftAnimationViewDelegate rightDebugView.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.3]; rightDebugView.frame = [self getRightZone]; rightDebugView.userInteractionEnabled = NO; + rightDebugView.tag = 999; // 设置debug视图tag [self.bannerContainer addSubview:rightDebugView]; NSLog(@"🎨 区域调试视图已添加"); @@ -451,6 +454,24 @@ XPRoomGraffitiGiftAnimationViewDelegate #endif } +- (void)ensureDebugViewsExist { + #ifdef DEBUG + // 检查是否已经有debug视图 + BOOL hasDebugViews = NO; + for (UIView *subview in self.bannerContainer.subviews) { + if (subview.tag == 999) { + hasDebugViews = YES; + break; + } + } + + if (!hasDebugViews) { + NSLog(@"🎨 重新添加debug视图"); + [self addZoneDebugViews]; + } + #endif +} + #pragma mark - UIGestureRecognizerDelegate - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { @@ -814,7 +835,23 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG } - (void)handleSwipeOutBanner { + NSLog(@"🚨 发送SwipeOutBanner通知 - 当前状态: isRoomBannerV2Displaying=%@", self.isRoomBannerV2Displaying ? @"YES" : @"NO"); + + // 防止重复处理 + if (!self.isRoomBannerV2Displaying) { + NSLog(@"🚨 警告: 尝试关闭banner但状态显示没有正在显示的banner"); + return; + } + + // 立即设置状态为NO,防止重复处理 + self.isRoomBannerV2Displaying = NO; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SwipeOutBanner" object:nil]; + + // 延迟处理下一个banner,确保当前banner完全关闭 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self processNextRoomEffectAttachment]; + }); } #pragma mark - Banner Interaction Management @@ -1183,8 +1220,71 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG } #pragma mark - Method: Banner -- (void)inserBannerModelToQueue:(id)obj { +- (void)inserBannerModelToQueue:(AttachmentModel *)obj { + // 参数验证 + if (!obj || ![obj isKindOfClass:[AttachmentModel class]]) { + NSLog(@"⚠️ 警告: inserBannerModelToQueue 接收到无效参数: %@", obj); + return; + } + + #ifdef DEBUG + // DEBUG环境:复制banner数据用于测试 + BOOL enableBannerCopy = YES; // 设置为NO可以禁用复制功能 + NSInteger copyCount = 10; // 可以调整这个数字来改变复制数量 + + if (enableBannerCopy) { + NSLog(@"🧪 DEBUG环境:收到banner数据,复制%ld份用于测试", (long)copyCount); + NSLog(@"🧪 原始banner类型: %@", NSStringFromClass([obj class])); + + // 添加原始数据 + [self.roomBannertModelsQueueV2 addObject:obj]; + + // 复制指定份数 + for (int i = 1; i < copyCount; i++) { + AttachmentModel *copiedObj = [[AttachmentModel alloc] init]; + + // 安全复制data + if ([obj.data respondsToSelector:@selector(mutableCopy)]) { + copiedObj.data = [obj.data mutableCopy]; + } else if ([obj.data respondsToSelector:@selector(copy)]) { + copiedObj.data = [obj.data copy]; + } else { + copiedObj.data = obj.data; // 直接引用,注意这可能不是深拷贝 + } + + copiedObj.first = obj.first; + copiedObj.second = obj.second; + copiedObj.isBroadcast = obj.isBroadcast; + copiedObj.seq = obj.seq; + + NSLog(@"🧪 复制第%d份banner数据", i + 1); + [self.roomBannertModelsQueueV2 addObject:copiedObj]; + } + + NSLog(@"🧪 队列中banner总数: %ld", (long)self.roomBannertModelsQueueV2.count); + + // 显示队列中banner类型的分布 + NSMutableDictionary *typeCount = [NSMutableDictionary dictionary]; + for (AttachmentModel *banner in self.roomBannertModelsQueueV2) { + NSString *typeKey = [NSString stringWithFormat:@"%d", banner.second]; + NSNumber *count = typeCount[typeKey]; + typeCount[typeKey] = @(count.integerValue + 1); + } + + NSLog(@"🧪 队列中banner类型分布:"); + for (NSString *typeKey in typeCount.allKeys) { + NSLog(@" - 类型%@: %@个", typeKey, typeCount[typeKey]); + } + } else { + // 禁用复制功能,正常添加 + NSLog(@"🧪 DEBUG环境:复制功能已禁用,正常添加banner"); + [self.roomBannertModelsQueueV2 addObject:obj]; + } + #else + // 生产环境:正常添加 [self.roomBannertModelsQueueV2 addObject:obj]; + #endif + if (!self.isRoomBannerV2Displaying) { [self processNextRoomEffectAttachment]; } @@ -1224,13 +1324,18 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG } - (void)processNextRoomEffectAttachment { + NSLog(@"🔄 processNextRoomEffectAttachment 被调用 - 当前状态: isRoomBannerV2Displaying=%@, 队列数量: %ld", + self.isRoomBannerV2Displaying ? @"YES" : @"NO", (long)self.roomBannertModelsQueueV2.count); + // 检查队列是否有元素 if (self.roomBannertModelsQueueV2.count == 0) { // 如果队列为空,停止处理 self.isRoomBannerV2Displaying = NO; + NSLog(@"🔄 队列为空,停止处理"); return; } if (self.isRoomBannerV2Displaying) { + NSLog(@"🔄 已有banner正在显示,跳过处理"); return; } @@ -1244,6 +1349,29 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG // 设置为正在显示的状态 self.isRoomBannerV2Displaying = YES; + NSLog(@"🔄 设置状态为正在显示: %@", NSStringFromClass([nextAttachment class])); + + // 清理之前的banner,防止多个banner同时显示(保留debug视图) + NSMutableArray *viewsToRemove = [NSMutableArray array]; + for (UIView *subview in self.bannerContainer.subviews) { + // 保留debug视图(tag为999的视图) + if (subview.tag == 999) { + NSLog(@"🔄 保留debug视图: %@", NSStringFromClass([subview class])); + } else { + // 其他视图都是banner,需要移除 + [viewsToRemove addObject:subview]; + NSLog(@"🔄 标记移除banner: %@", NSStringFromClass([subview class])); + } + } + + for (UIView *view in viewsToRemove) { + [view removeFromSuperview]; + } + + NSLog(@"🔄 清理了 %ld 个banner视图,保留debug视图", (long)viewsToRemove.count); + + // 确保debug视图存在 + [self ensureDebugViewsExist]; switch (nextAttachment.second) { case Custom_Message_Sub_General_Floating_Screen_One_Room: @@ -1291,6 +1419,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:obj complete:^{ @kStrongify(self); + NSLog(@"🔄 BravoGiftBannerView complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; } exitCurrentRoom:^{ @@ -1306,6 +1435,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } @@ -1323,6 +1455,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:obj complete:^{ @kStrongify(self); + NSLog(@"🔄 LuckyPackageBannerView complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; } exitCurrentRoom:^{ @@ -1338,6 +1471,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } @@ -1357,6 +1493,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:obj complete:^{ @kStrongify(self); + NSLog(@"🔄 RoomHighValueGiftBannerAnimation complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; }]; @@ -1369,6 +1506,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } @@ -1393,6 +1533,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:attachMent complete:^{ @kStrongify(self); + NSLog(@"🔄 CPGiftBanner complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; }]; @@ -1405,6 +1546,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } @@ -1570,6 +1714,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:nextAttachment complete:^{ @kStrongify(self); + NSLog(@"🔄 LuckyGiftWinningBannerView complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; } exitCurrentRoom:^{ @@ -1585,6 +1730,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } @@ -1618,6 +1766,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG with:attachment complete:^{ @kStrongify(self); + NSLog(@"🔄 GameUniversalBannerView complete 回调被调用"); self.isRoomBannerV2Displaying = NO; [self processNextRoomEffectAttachment]; } goToGame:^(NSInteger gameID) { @@ -1662,6 +1811,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG break; } } + + // 确保debug视图存在 + [self ensureDebugViewsExist]; }); } diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomHighValueGiftBannerAnimation.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomHighValueGiftBannerAnimation.m index 74470234..a6477a91 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomHighValueGiftBannerAnimation.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomHighValueGiftBannerAnimation.m @@ -125,11 +125,15 @@ } - (void)dismissBanner { + NSLog(@"🚨 RoomHighValueGiftBannerAnimation dismissBanner 被调用"); [self pop_removeAllAnimations]; // 停止所有动画 [self popLeaveAnimation:^(bool finished) { + NSLog(@"🚨 RoomHighValueGiftBannerAnimation 动画完成,调用回调"); if (self.animationComplete) { self.animationComplete(); + } else { + NSLog(@"🚨 警告: animationComplete 回调为空"); } [self removeFromSuperview]; }];