fix 分享视图横竖屏切换时现实异常问题

master
wanghualei 2022-08-23 17:53:47 +08:00
parent 5df1a9e0de
commit 69d26d667e
1 changed files with 13 additions and 0 deletions

View File

@ -88,6 +88,7 @@ returnInsets = inset;\
[self.contentView addSubview:self.collectionView]; [self.contentView addSubview:self.collectionView];
self.collectionView.frame = CGRectMake(0, 0, frame.size.width, 100); self.collectionView.frame = CGRectMake(0, 0, frame.size.width, 100);
[self p_addNotifications];
} }
return self; return self;
} }
@ -96,6 +97,18 @@ returnInsets = inset;\
return [[self alloc] initWithFrame:[UIScreen mainScreen].bounds]; 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 { - (void)show {
if (self.superview) { if (self.superview) {
return; return;