Files
real-e-party-iOS/YuMi/Modules/YMRoom/Manager/GameBannerGestureManager.m
edwinQQQ a35a711be6 chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
2025-10-09 16:19:14 +08:00

90 lines
2.8 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// GameBannerGestureManager.m
#import "GameBannerGestureManager.h"
@interface GameBannerGestureManager ()
@property (nonatomic, assign) BOOL isEnabled;
@property (nonatomic, strong) UISwipeGestureRecognizer *swipeGesture;
@end
@implementation GameBannerGestureManager
- (void)enableGestureForGameMode {
if (self.isEnabled) return;
[self cleanupAllGestures];
// 创建新的 swipe 手势
self.swipeGesture = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe)];
// 配置手势识别器,确保不拦截触摸事件
self.swipeGesture.delaysTouchesBegan = NO;
self.swipeGesture.delaysTouchesEnded = NO;
self.swipeGesture.cancelsTouchesInView = NO;
self.swipeGesture.requiresExclusiveTouchType = NO;
// 设置 swipe 方向
if (isMSRTL()) {
self.swipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
} else {
self.swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;
}
[self.bannerContainer addGestureRecognizer:self.swipeGesture];
_isEnabled = YES;
NSLog(@"🎮 GameBannerGestureManager: swipe 手势已启用");
}
- (void)disableGestureForGameMode {
if (!self.isEnabled) return;
[self cleanupAllGestures];
_isEnabled = NO;
NSLog(@"🎮 GameBannerGestureManager: swipe 手势已禁用");
}
- (void)cleanupAllGestures {
if (self.swipeGesture) {
[self.bannerContainer removeGestureRecognizer:self.swipeGesture];
self.swipeGesture = nil;
}
// 清理可能存在的其他手势识别器
NSArray *gestures = [self.bannerContainer.gestureRecognizers copy];
for (UIGestureRecognizer *gesture in gestures) {
if ([gesture isKindOfClass:[UISwipeGestureRecognizer class]]) {
[self.bannerContainer removeGestureRecognizer:gesture];
}
}
}
- (void)resetState {
[self cleanupAllGestures];
_isEnabled = NO;
}
- (void)handleSwipe {
NSLog(@"🎮 GameBannerGestureManager: 检测到 swipe 手势,发送 banner 移除通知");
// 检查当前是否有可见的 banner
UIView *currentVisibleBanner = nil;
for (UIView *subview in self.bannerContainer.subviews) {
if (!subview.hidden && subview.alpha > 0.01) {
currentVisibleBanner = subview;
break;
}
}
if (currentVisibleBanner) {
NSLog(@"🎮 当前有可见 banner: %@,发送 SwipeOutBanner 通知", NSStringFromClass([currentVisibleBanner class]));
[[NSNotificationCenter defaultCenter] postNotificationName:@"SwipeOutBanner"
object:currentVisibleBanner];
} else {
NSLog(@"🎮 当前没有可见 banner忽略 swipe 手势");
}
}
@end