@@ -13,6 +13,43 @@ class Responder extends UIResponder {
13
13
//
14
14
}
15
15
16
+ class RootViewControllerImpl extends UIViewController implements definition . RootViewControllerImpl {
17
+ private _contentController : UIViewController ;
18
+
19
+ get contentController ( ) : UIViewController {
20
+ return this . _contentController ;
21
+ }
22
+
23
+ set contentController ( contentController : UIViewController ) {
24
+
25
+ if ( contentController . parentViewController !== null ) {
26
+ contentController . willMoveToParentViewController ( null ) ;
27
+ contentController . view . removeFromSuperview ( ) ;
28
+ contentController . removeFromParentViewController ( ) ;
29
+ contentController . didMoveToParentViewController ( this ) ;
30
+ }
31
+
32
+ if ( this . _contentController ) {
33
+ this . _contentController . willMoveToParentViewController ( null ) ;
34
+ this . _contentController . view . removeFromSuperview ( ) ;
35
+ this . _contentController . removeFromParentViewController ( ) ;
36
+ }
37
+
38
+ this . addChildViewController ( contentController ) ;
39
+ this . view . addSubview ( contentController . view ) ;
40
+ contentController . view . frame = this . view . bounds ;
41
+ contentController . view . autoresizingMask = UIViewAutoresizing . UIViewAutoresizingFlexibleWidth | UIViewAutoresizing . UIViewAutoresizingFlexibleHeight ;
42
+
43
+ this . _contentController = contentController ;
44
+ this . _contentController . didMoveToParentViewController ( this ) ;
45
+ }
46
+
47
+ public viewDidLoad ( ) : void {
48
+ super . viewDidLoad ( ) ;
49
+ this . view . backgroundColor = UIColor . whiteColor ( ) ;
50
+ }
51
+ }
52
+
16
53
class Window extends UIWindow {
17
54
18
55
private _content ;
@@ -140,11 +177,13 @@ class IOSApplication implements definition.iOSApplication {
140
177
141
178
rootView = frame ;
142
179
}
143
-
180
+
144
181
this . _window . content = rootView ;
145
182
146
183
if ( rootView instanceof Frame ) {
147
- this . rootController = this . _window . rootViewController = rootView . ios . controller ;
184
+ let rootController = new RootViewControllerImpl ( ) ;
185
+ this . rootController = this . _window . rootViewController = rootController ;
186
+ rootController . contentController = rootView . ios . controller ;
148
187
}
149
188
else if ( rootView . ios instanceof UIViewController ) {
150
189
this . rootController = this . _window . rootViewController = rootView . ios ;
0 commit comments