Skip to content

Commit

Permalink
Merge pull request #33 from zhugeafanti/master
Browse files Browse the repository at this point in the history
feat: Unipage adds postCreate lifecycle method
  • Loading branch information
maxiee authored Sep 23, 2024
2 parents 53c0e1e + df9b2ef commit 045e3a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/unify_uni_page/ios/Classes/UniPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN
/// create生命周期,用户通过override此接口创建原生视图元素
- (void)onCreate;

/// postCreate生命周期,在UniPage已被创建要layout时,用户通过override此接口, 注入逻辑
- (void)postCreate;

/// 销毁生命周期,可以通过override此接口处理销毁后续工作
- (void)onDispose;

Expand Down
13 changes: 13 additions & 0 deletions packages/unify_uni_page/ios/Classes/UniPage.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @interface UniPage()<FlutterPlatformView>
@property (nonatomic, assign) int64_t viewId;
@property (nonatomic, strong) NSDictionary *arguments;
@property (nonatomic, strong) FlutterMethodChannel *channel;
@property (nonatomic, assign) BOOL isPosted;

@end

Expand Down Expand Up @@ -54,6 +55,14 @@ - (instancetype)initWithWithFrame:(CGRect)frame
return self;
}

- (void)layoutSubviews {
[super layoutSubviews];
if (!self.isPosted) {
[self postCreate];
self.isPosted = YES;
}
}

#pragma - public methods

- (void)pushNamed:(NSString*)routePath param:(NSDictionary *)args {
Expand Down Expand Up @@ -118,6 +127,10 @@ - (void)onCreate {

}

- (void)postCreate {

}

- (void)onForeground {

}
Expand Down

0 comments on commit 045e3a0

Please sign in to comment.