comparison ios/dw.m @ 2599:32728f6f7ccd

iOS: Add UINavigationBar and DWView to the rootViewController's view. Instead of adding them directly to the DWWindow, so we don't need to hide the UITransitionView, so remove that code as well.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 10 Jul 2021 23:57:25 +0000
parents 4a5364fe65b7
children 0bb974e70435
comparison
equal deleted inserted replaced
2598:4a5364fe65b7 2599:32728f6f7ccd
1360 1360
1361 @implementation DWViewController : UIViewController {} 1361 @implementation DWViewController : UIViewController {}
1362 -(void)viewWillLayoutSubviews 1362 -(void)viewWillLayoutSubviews
1363 { 1363 {
1364 DWWindow *window = (DWWindow *)[[self view] window]; 1364 DWWindow *window = (DWWindow *)[[self view] window];
1365 NSArray *array = [window subviews]; 1365 NSArray *array = [[self view] subviews];
1366 CGRect frame = [window frame]; 1366 CGRect frame = [window frame];
1367 DWView *view = nil; 1367 DWView *view = nil;
1368 UINavigationBar *nav = nil; 1368 UINavigationBar *nav = nil;
1369 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height; 1369 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height;
1370 1370
1372 { 1372 {
1373 if([obj isMemberOfClass:[DWView class]]) 1373 if([obj isMemberOfClass:[DWView class]])
1374 view = obj; 1374 view = obj;
1375 else if([obj isMemberOfClass:[UINavigationBar class]]) 1375 else if([obj isMemberOfClass:[UINavigationBar class]])
1376 nav = obj; 1376 nav = obj;
1377 /* Hide the UITransitionView which is blocking the screen...
1378 * This is probably not the correct solution, but it solves the
1379 * problem for the moment. Figure out what to do with this view.
1380 */
1381 else
1382 [obj setHidden:YES];
1383 } 1377 }
1384 /* Adjust the frame to account for the status bar and navigation bar if it exists */ 1378 /* Adjust the frame to account for the status bar and navigation bar if it exists */
1385 if(nav) 1379 if(nav)
1386 { 1380 {
1387 CGRect navrect = [nav frame]; 1381 CGRect navrect = [nav frame];
3789 3783
3790 /* Query the objects */ 3784 /* Query the objects */
3791 if([object isKindOfClass:[UIWindow class]]) 3785 if([object isKindOfClass:[UIWindow class]])
3792 { 3786 {
3793 UIWindow *window = box; 3787 UIWindow *window = box;
3794 NSArray *subviews = [window subviews]; 3788 NSArray *subviews = [[[window rootViewController] view] subviews];
3795 view = [subviews firstObject]; 3789 view = [subviews firstObject];
3796 } 3790 }
3797 else if([object isMemberOfClass:[DWScrollBox class]]) 3791 else if([object isMemberOfClass:[DWScrollBox class]])
3798 { 3792 {
3799 DWScrollBox *scrollbox = box; 3793 DWScrollBox *scrollbox = box;
7965 CGRect screenrect = [[UIScreen mainScreen] bounds]; 7959 CGRect screenrect = [[UIScreen mainScreen] bounds];
7966 DWWindow *window = [[DWWindow alloc] initWithFrame:screenrect]; 7960 DWWindow *window = [[DWWindow alloc] initWithFrame:screenrect];
7967 DWView *view = [[DWView alloc] init]; 7961 DWView *view = [[DWView alloc] init];
7968 UIUserInterfaceStyle style = [[DWObj hiddenWindow] overrideUserInterfaceStyle]; 7962 UIUserInterfaceStyle style = [[DWObj hiddenWindow] overrideUserInterfaceStyle];
7969 7963
7964 /* Copy the overrideUserInterfaceStyle property from the hiddenWindow */
7965 if(style != UIUserInterfaceStyleUnspecified)
7966 [window setOverrideUserInterfaceStyle:style];
7970 [window setWindowLevel:UIWindowLevelNormal]; 7967 [window setWindowLevel:UIWindowLevelNormal];
7971 [window setRootViewController:[[DWViewController alloc] init]]; 7968 [window setRootViewController:[[DWViewController alloc] init]];
7972 [window addSubview:view];
7973 [window setBackgroundColor:[UIColor systemBackgroundColor]]; 7969 [window setBackgroundColor:[UIColor systemBackgroundColor]];
7970 [[[window rootViewController] view] addSubview:view];
7974 7971
7975 /* Handle style flags... There is no visible frame... 7972 /* Handle style flags... There is no visible frame...
7976 * On iOS 13 and higher if a titlebar is requested create a navigation bar. 7973 * On iOS 13 and higher if a titlebar is requested create a navigation bar.
7977 */ 7974 */
7978 if(@available(iOS 13.0, *)) { 7975 if(@available(iOS 13.0, *)) {
7983 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height; 7980 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height;
7984 UINavigationBar* navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, sbheight, screenrect.size.width, 40)]; 7981 UINavigationBar* navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, sbheight, screenrect.size.width, 40)];
7985 UINavigationItem* navItem = [[UINavigationItem alloc] initWithTitle:nstitle]; 7982 UINavigationItem* navItem = [[UINavigationItem alloc] initWithTitle:nstitle];
7986 7983
7987 [navbar setItems:@[navItem]]; 7984 [navbar setItems:@[navItem]];
7988 [window addSubview:navbar]; 7985 [[[window rootViewController] view] addSubview:navbar];
7989 } 7986 }
7990 } 7987 }
7991 /* Copy the overrideUserInterfaceStyle property from the hiddenWindow */
7992 if(style != UIUserInterfaceStyleUnspecified)
7993 [window setOverrideUserInterfaceStyle:style];
7994 DW_FUNCTION_RETURN_THIS(window); 7988 DW_FUNCTION_RETURN_THIS(window);
7995 } 7989 }
7996 7990
7997 /* 7991 /*
7998 * Call a function from the window (widget)'s context. 7992 * Call a function from the window (widget)'s context.