新增连击状态管理功能,包含强制重置连击状态的方法和应用生命周期保护;在 XPSendGiftView 和 GiftComboManager 中实现相关逻辑,确保 UI 状态与连击状态一致;注册通知以处理连击状态的强制重置,增强用户体验和系统稳定性。
This commit is contained in:
@@ -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];
|
||||
|
Reference in New Issue
Block a user