Pārlūkot izejas kodu

trying to fix multiple modal dismissal

Daniel Zlotin 7 gadus atpakaļ
vecāks
revīzija
853ed4aa17

+ 0
- 1
ios/RNNModalManager.m Parādīt failu

@@ -27,7 +27,6 @@
27 27
 	[[_store pendingModalIdsToDismiss] removeAllObjects];
28 28
 }
29 29
 
30
-
31 30
 #pragma mark - private
32 31
 
33 32
 

+ 0
- 4
ios/RNNReactRootViewCreator.m Parādīt failu

@@ -8,10 +8,6 @@
8 8
 
9 9
 @implementation RNNReactRootView
10 10
 
11
--(void)dealloc {
12
-	
13
-}
14
-
15 11
 @end
16 12
 
17 13
 @implementation RNNReactRootViewCreator {

+ 11
- 12
ios/RNNRootViewController.m Parādīt failu

@@ -17,7 +17,10 @@
17 17
 	
18 18
 	self.view = [creator createRootView:self.containerName rootViewId:self.containerId];
19 19
 	
20
-//	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJsReload) name:RCTJavaScriptWillStartLoadingNotification object:nil];
20
+	[[NSNotificationCenter defaultCenter] addObserver:self
21
+											 selector:@selector(onJsReload)
22
+												 name:RCTJavaScriptWillStartLoadingNotification
23
+											   object:nil];
21 24
 	
22 25
 	return self;
23 26
 }
@@ -32,17 +35,13 @@
32 35
 	[self.eventEmitter sendContainerStop:self.containerId];
33 36
 }
34 37
 
35
-///**
36
-// * fix for 
37
-// */
38
-//-(void)onJsReload {
39
-//	[[NSNotificationCenter defaultCenter] removeObserver:self];
40
-//	[[NSNotificationCenter defaultCenter] removeObserver:self.view];
41
-//	self.view = nil;
42
-//}
43
-
44
--(void)dealloc {
45
-	
38
+/**
39
+ *	fix for #877
40
+ */
41
+-(void)onJsReload {
42
+	[[NSNotificationCenter defaultCenter] removeObserver:self];
43
+	[[NSNotificationCenter defaultCenter] removeObserver:self.view];
44
+	self.view = nil;
46 45
 }
47 46
 
48 47
 @end

+ 23
- 11
ios/ReactNativeNavigation.m Parādīt failu

@@ -17,8 +17,11 @@
17 17
 @implementation ReactNativeNavigation {
18 18
 	NSURL* _jsCodeLocation;
19 19
 	NSDictionary* _launchOptions;
20
-	RNNStore* _store;
21 20
 	RCTBridge* _bridge;
21
+	
22
+	RNNStore* _store;
23
+	
24
+	RNNCommandsHandler* _commandsHandler;
22 25
 }
23 26
 
24 27
 # pragma mark - public API
@@ -67,8 +70,8 @@
67 70
 	
68 71
 	id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge];
69 72
 	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator store:_store eventEmitter:eventEmitter];
70
-	RNNCommandsHandler *commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
71
-	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:commandsHandler];
73
+	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
74
+	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
72 75
 	
73 76
 	return @[bridgeModule,eventEmitter];
74 77
 }
@@ -76,7 +79,7 @@
76 79
 # pragma mark - js events
77 80
 
78 81
 -(void)onJavaScriptWillLoad {
79
-	[self resetRootViewControllerOnlyOnJSDevReload];
82
+	[self releaseBeforeJSReload];
80 83
 	[_store clean];
81 84
 }
82 85
 
@@ -102,16 +105,25 @@
102 105
 											   object:nil];
103 106
 }
104 107
 
105
--(void)resetRootViewControllerOnlyOnJSDevReload {
108
+-(void)releaseBeforeJSReload {
106 109
 #ifdef DEBUG
107
-	
108
-	if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
109
-		UIApplication.sharedApplication.delegate.window.rootViewController = nil;
110
-	}
111
-	
110
+//	if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
111
+//		[self releaseBeforeJsReload:UIApplication.sharedApplication.delegate.window.rootViewController];
112
+//	}
112 113
 #endif
113 114
 }
114 115
 
115
-
116
+//-(void)releaseBeforeJsReload:(UIViewController*)vc {
117
+//	if(!vc) return;
118
+//	
119
+//	for (UIViewController* child in vc.childViewControllers) {
120
+//		[self releaseBeforeJsReload:child];
121
+//	}
122
+//	[self releaseBeforeJsReload:vc.presentedViewController];
123
+//	
124
+//	[NSNotificationCenter.defaultCenter removeObserver:vc];
125
+//	[NSNotificationCenter.defaultCenter removeObserver:vc.view];
126
+//	vc.view = nil;
127
+//}
116 128
 
117 129
 @end