mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-23 04:00:15 +08:00
Add lifecycle aware view managers to Example app
This commit is contained in:
33
Example/ios/ScreensExample/RNSSampleLifecycleAwareView.m
Normal file
33
Example/ios/ScreensExample/RNSSampleLifecycleAwareView.m
Normal file
@@ -0,0 +1,33 @@
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RNSLifecycleAwareView : UIView
|
||||
@end
|
||||
|
||||
@implementation RNSLifecycleAwareView
|
||||
|
||||
- (void)didMoveToWindow
|
||||
{
|
||||
[super didMoveToWindow];
|
||||
BOOL isVisible = self.superview && self.window;
|
||||
if (isVisible) {
|
||||
NSLog(@"ATTACHED");
|
||||
} else {
|
||||
NSLog(@"DETTACHED");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface RNSLifecycleAwareViewManager : RCTViewManager
|
||||
@end
|
||||
|
||||
@implementation RNSLifecycleAwareViewManager
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [RNSLifecycleAwareView new];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user