新增连击状态管理功能,包含强制重置连击状态的方法和应用生命周期保护;在 XPSendGiftView 和 GiftComboManager 中实现相关逻辑,确保 UI 状态与连击状态一致;注册通知以处理连击状态的强制重置,增强用户体验和系统稳定性。

This commit is contained in:
edwinQQQ
2025-08-11 14:51:57 +08:00
parent 1fb6cadabf
commit c0bc29486f
10 changed files with 195 additions and 3 deletions

View File

@@ -364,6 +364,12 @@ XPCandyTreeInsufficientBalanceViewDelegate>
dispatch_async(dispatch_get_main_queue(), ^{
self.sideMenu.hidden = comboViewDisplay;
self.menuContainerView.hidden = comboViewDisplay;
// UI
if (comboViewDisplay && ![[GiftComboManager sharedManager] isGiftCombing]) {
NSLog(@"⚠️ 检测到UI隐藏请求但连击未进行执行强制重置");
[self forceBoomStateReset];
}
});
}];
}
@@ -415,6 +421,12 @@ XPCandyTreeInsufficientBalanceViewDelegate>
- (void)setupNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myGiftEffectUpdate:) name:kRoomGiftEffectUpdateNotificationKey object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openRedPacketNotification:) name:@"kOpenRedPacketNotification" object:nil];
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
@kWeakify(self);
[[NSNotificationCenter defaultCenter] addObserverForName:@"kExchangeRoomAnimationViewAndGameViewIndex"
@@ -497,6 +509,12 @@ XPCandyTreeInsufficientBalanceViewDelegate>
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
self.freeView.hidden = YES;
//
if ([[GiftComboManager sharedManager] isGiftCombing]) {
NSLog(@"📱 房间即将退出,检查连击状态");
[self forceBoomStateReset];
}
}
- (void)viewDidDisappear:(BOOL)animated{
@@ -511,6 +529,41 @@ XPCandyTreeInsufficientBalanceViewDelegate>
[XPSkillCardPlayerManager shareInstance].isInRoomVC = YES;
}
#pragma mark -
// UI
- (void)forceBoomStateReset {
NSLog(@"🔧 XPRoomViewController 强制重置连击状态");
// 1.
[[GiftComboManager sharedManager] forceBoomStateReset];
// 2. UI
dispatch_async(dispatch_get_main_queue(), ^{
self.sideMenu.hidden = NO;
self.menuContainerView.hidden = NO;
NSLog(@"🔄 强制恢复底部操作栏和侧栏显示");
});
}
//
- (void)applicationDidEnterBackground:(NSNotification *)notification {
if ([[GiftComboManager sharedManager] isGiftCombing]) {
NSLog(@"📱 应用进入后台,检查连击状态");
[self forceBoomStateReset];
}
}
//
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
if ([[GiftComboManager sharedManager] isGiftCombing]) {
NSLog(@"⚠️ 收到内存警告,检查连击状态");
[self forceBoomStateReset];
}
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor darkGrayColor];