fix: the timing of iOS's onShow call

This commit is contained in:
pengfei.zhou 2022-06-02 19:40:17 +08:00 committed by osborn
parent 531e2d9298
commit e62bfa315e

View File

@ -23,6 +23,7 @@
@interface DoricPanel () @interface DoricPanel ()
@property(nonatomic, assign) CGFloat renderedWidth; @property(nonatomic, assign) CGFloat renderedWidth;
@property(nonatomic, assign) CGFloat renderedHeight; @property(nonatomic, assign) CGFloat renderedHeight;
@property(nonatomic, assign) BOOL isShow;
@end @end
@implementation DoricPanel @implementation DoricPanel
@ -47,9 +48,6 @@ - (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extr
[self.view addSubview:it]; [self.view addSubview:it];
}]]; }]];
}]; }];
if (self.parentViewController != nil) {
[self.doricContext onShow];
}
} }
- (void)viewWillLayoutSubviews { - (void)viewWillLayoutSubviews {
@ -58,17 +56,27 @@ - (void)viewWillLayoutSubviews {
self.renderedWidth = self.view.width; self.renderedWidth = self.view.width;
self.renderedHeight = self.view.height; self.renderedHeight = self.view.height;
[self.doricContext build:CGSizeMake(self.renderedWidth, self.renderedHeight)]; [self.doricContext build:CGSizeMake(self.renderedWidth, self.renderedHeight)];
if (!self.isShow) {
self.isShow = YES;
[self.doricContext onShow];
}
} }
} }
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self.doricContext onShow]; if (self.doricContext && !self.isShow) {
self.isShow = YES;
[self.doricContext onShow];
}
} }
- (void)viewDidDisappear:(BOOL)animated { - (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
[self.doricContext onHidden]; if (self.isShow) {
self.isShow = NO;
[self.doricContext onHidden];
}
} }
@end @end