From 69d26d667e1df718941a8c7337694c061b086bbc Mon Sep 17 00:00:00 2001 From: wanghualei Date: Tue, 23 Aug 2022 17:53:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=86=E4=BA=AB=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E6=A8=AA=E7=AB=96=E5=B1=8F=E5=88=87=E6=8D=A2=E6=97=B6=E7=8E=B0?= =?UTF-8?q?=E5=AE=9E=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOP_showBotomSheetModel.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ios/Classes/Api/MOP_showBotomSheetModel.m b/ios/Classes/Api/MOP_showBotomSheetModel.m index 8c0922b..f91426b 100644 --- a/ios/Classes/Api/MOP_showBotomSheetModel.m +++ b/ios/Classes/Api/MOP_showBotomSheetModel.m @@ -88,6 +88,7 @@ returnInsets = inset;\ [self.contentView addSubview:self.collectionView]; self.collectionView.frame = CGRectMake(0, 0, frame.size.width, 100); + [self p_addNotifications]; } return self; } @@ -96,6 +97,18 @@ returnInsets = inset;\ return [[self alloc] initWithFrame:[UIScreen mainScreen].bounds]; } +- (void)p_addNotifications { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil]; +} + +- (void)deviceOrientationDidChange { + CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; + CGFloat currentWidth = self.frame.size.width; + if (screenWidth != currentWidth) { + [self removeFromSuperview]; + } +} + - (void)show { if (self.superview) { return;