在多个视图的 dismissBanner 方法中新增日志输出,以便于调试和监控动画完成状态;在 RoomAnimationView 中新增 ensureDebugViewsExist 方法,确保调试视图的存在并优化调试信息的输出;在 inserBannerModelToQueue 方法中添加参数验证和调试信息,提升代码的可读性和调试能力。

This commit is contained in:
edwinQQQ
2025-08-13 18:16:46 +08:00
parent 9206b4be45
commit 3da0148ad1
4 changed files with 165 additions and 1 deletions

View File

@@ -77,12 +77,16 @@
} }
- (void)dismissBanner { - (void)dismissBanner {
NSLog(@"🚨 GameUniversalBannerView dismissBanner 被调用");
self.alreadyCancel = YES; self.alreadyCancel = YES;
[self pop_removeAllAnimations]; // [self pop_removeAllAnimations]; //
[self popLeaveAnimation:^(bool finished) { [self popLeaveAnimation:^(bool finished) {
NSLog(@"🚨 GameUniversalBannerView 动画完成,调用回调");
if (self.completeDisplay) { if (self.completeDisplay) {
self.completeDisplay(); self.completeDisplay();
} else {
NSLog(@"🚨 警告: completeDisplay 回调为空");
} }
[self removeFromSuperview]; [self removeFromSuperview];
}]; }];

View File

@@ -133,11 +133,15 @@ exitCurrentRoom:(void(^)(void))exit {
} }
- (void)dismissBanner { - (void)dismissBanner {
NSLog(@"🚨 LuckyGiftWinningBannerView dismissBanner 被调用");
[self pop_removeAllAnimations]; // [self pop_removeAllAnimations]; //
[self popLeaveAnimation:^(bool finished) { [self popLeaveAnimation:^(bool finished) {
NSLog(@"🚨 LuckyGiftWinningBannerView 动画完成,调用回调");
if (self.completeDisplay) { if (self.completeDisplay) {
self.completeDisplay(); self.completeDisplay();
} else {
NSLog(@"🚨 警告: completeDisplay 回调为空");
} }
[self removeFromSuperview]; [self removeFromSuperview];
}]; }];

View File

@@ -421,6 +421,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
centerDebugView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3]; centerDebugView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3];
centerDebugView.frame = [self getCenterZone]; centerDebugView.frame = [self getCenterZone];
centerDebugView.userInteractionEnabled = NO; centerDebugView.userInteractionEnabled = NO;
centerDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:centerDebugView]; [self.bannerContainer addSubview:centerDebugView];
// - // -
@@ -428,6 +429,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
leftDebugView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.3]; leftDebugView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.3];
leftDebugView.frame = [self getLeftZone]; leftDebugView.frame = [self getLeftZone];
leftDebugView.userInteractionEnabled = NO; leftDebugView.userInteractionEnabled = NO;
leftDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:leftDebugView]; [self.bannerContainer addSubview:leftDebugView];
// - 绿 // - 绿
@@ -435,6 +437,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
rightDebugView.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.3]; rightDebugView.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
rightDebugView.frame = [self getRightZone]; rightDebugView.frame = [self getRightZone];
rightDebugView.userInteractionEnabled = NO; rightDebugView.userInteractionEnabled = NO;
rightDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:rightDebugView]; [self.bannerContainer addSubview:rightDebugView];
NSLog(@"🎨 区域调试视图已添加"); NSLog(@"🎨 区域调试视图已添加");
@@ -451,6 +454,24 @@ XPRoomGraffitiGiftAnimationViewDelegate
#endif #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 #pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
@@ -814,7 +835,23 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
} }
- (void)handleSwipeOutBanner { - (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]; [[NSNotificationCenter defaultCenter] postNotificationName:@"SwipeOutBanner" object:nil];
// bannerbanner
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 #pragma mark - Banner Interaction Management
@@ -1183,8 +1220,71 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
} }
#pragma mark - Method: Banner #pragma mark - Method: Banner
- (void)inserBannerModelToQueue:(id)obj { - (void)inserBannerModelToQueue:(AttachmentModel *)obj {
//
if (!obj || ![obj isKindOfClass:[AttachmentModel class]]) {
NSLog(@"⚠️ 警告: inserBannerModelToQueue 接收到无效参数: %@", obj);
return;
}
#ifdef DEBUG
// DEBUGbanner
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]; [self.roomBannertModelsQueueV2 addObject:obj];
#endif
if (!self.isRoomBannerV2Displaying) { if (!self.isRoomBannerV2Displaying) {
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
} }
@@ -1224,13 +1324,18 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
} }
- (void)processNextRoomEffectAttachment { - (void)processNextRoomEffectAttachment {
NSLog(@"🔄 processNextRoomEffectAttachment 被调用 - 当前状态: isRoomBannerV2Displaying=%@, 队列数量: %ld",
self.isRoomBannerV2Displaying ? @"YES" : @"NO", (long)self.roomBannertModelsQueueV2.count);
// //
if (self.roomBannertModelsQueueV2.count == 0) { if (self.roomBannertModelsQueueV2.count == 0) {
// //
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
NSLog(@"🔄 队列为空,停止处理");
return; return;
} }
if (self.isRoomBannerV2Displaying) { if (self.isRoomBannerV2Displaying) {
NSLog(@"🔄 已有banner正在显示跳过处理");
return; return;
} }
@@ -1244,6 +1349,29 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
// //
self.isRoomBannerV2Displaying = YES; self.isRoomBannerV2Displaying = YES;
NSLog(@"🔄 设置状态为正在显示: %@", NSStringFromClass([nextAttachment class]));
// bannerbannerdebug
NSMutableArray *viewsToRemove = [NSMutableArray array];
for (UIView *subview in self.bannerContainer.subviews) {
// debugtag999
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) { switch (nextAttachment.second) {
case Custom_Message_Sub_General_Floating_Screen_One_Room: case Custom_Message_Sub_General_Floating_Screen_One_Room:
@@ -1291,6 +1419,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:obj with:obj
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 BravoGiftBannerView complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
} exitCurrentRoom:^{ } exitCurrentRoom:^{
@@ -1306,6 +1435,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1323,6 +1455,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:obj with:obj
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 LuckyPackageBannerView complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
} exitCurrentRoom:^{ } exitCurrentRoom:^{
@@ -1338,6 +1471,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1357,6 +1493,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:obj with:obj
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 RoomHighValueGiftBannerAnimation complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
}]; }];
@@ -1369,6 +1506,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1393,6 +1533,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:attachMent with:attachMent
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 CPGiftBanner complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
}]; }];
@@ -1405,6 +1546,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1570,6 +1714,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:nextAttachment with:nextAttachment
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 LuckyGiftWinningBannerView complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
} exitCurrentRoom:^{ } exitCurrentRoom:^{
@@ -1585,6 +1730,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1618,6 +1766,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with:attachment with:attachment
complete:^{ complete:^{
@kStrongify(self); @kStrongify(self);
NSLog(@"🔄 GameUniversalBannerView complete 回调被调用");
self.isRoomBannerV2Displaying = NO; self.isRoomBannerV2Displaying = NO;
[self processNextRoomEffectAttachment]; [self processNextRoomEffectAttachment];
} goToGame:^(NSInteger gameID) { } goToGame:^(NSInteger gameID) {
@@ -1662,6 +1811,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }

View File

@@ -125,11 +125,15 @@
} }
- (void)dismissBanner { - (void)dismissBanner {
NSLog(@"🚨 RoomHighValueGiftBannerAnimation dismissBanner 被调用");
[self pop_removeAllAnimations]; // [self pop_removeAllAnimations]; //
[self popLeaveAnimation:^(bool finished) { [self popLeaveAnimation:^(bool finished) {
NSLog(@"🚨 RoomHighValueGiftBannerAnimation 动画完成,调用回调");
if (self.animationComplete) { if (self.animationComplete) {
self.animationComplete(); self.animationComplete();
} else {
NSLog(@"🚨 警告: animationComplete 回调为空");
} }
[self removeFromSuperview]; [self removeFromSuperview];
}]; }];